Skip to content

Commit 8e133ad

Browse files
Fix SentryUserInteractionWidget throwing when Sentry is not enabled (#1363)
Co-authored-by: Manoel Aranda Neto <[email protected]>
1 parent 8ced2dc commit 8e133ad

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Fix `SentryUserInteractionWidget` throwing when Sentry is not enabled ([#1363](https://github.com/getsentry/sentry-dart/pull/1363))
8+
39
## 7.3.0
410

511
### Features

flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ class SentryUserInteractionWidget extends StatefulWidget {
251251

252252
SentryFlutterOptions? get _options =>
253253
// ignore: invalid_use_of_internal_member
254-
_hub.options as SentryFlutterOptions?;
254+
_hub.options is SentryFlutterOptions
255+
// ignore: invalid_use_of_internal_member
256+
? _hub.options as SentryFlutterOptions
257+
: null;
255258

256259
@override
257260
StatefulElement createElement() {

flutter/test/user_interaction/sentry_user_interaction_widget_test.dart

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@TestOn('vm')
2-
32
// ignore_for_file: invalid_use_of_internal_member
43

54
import 'dart:async';
@@ -14,13 +13,26 @@ import '../mocks.dart';
1413
import '../mocks.mocks.dart';
1514

1615
void main() {
17-
group('$SentryUserInteractionWidget crumbs', () {
18-
late Fixture fixture;
19-
setUp(() async {
20-
fixture = Fixture();
21-
TestWidgetsFlutterBinding.ensureInitialized();
22-
});
16+
late Fixture fixture;
17+
setUp(() async {
18+
fixture = Fixture();
19+
TestWidgetsFlutterBinding.ensureInitialized();
20+
});
21+
22+
testWidgets(
23+
'$SentryUserInteractionWidget does not throw cast exception when Sentry is disabled',
24+
(tester) async {
25+
await tester.runAsync(() async {
26+
await tester.pumpWidget(
27+
SentryUserInteractionWidget(
28+
child: MaterialApp(),
29+
),
30+
);
31+
});
32+
},
33+
);
2334

35+
group('$SentryUserInteractionWidget crumbs', () {
2436
testWidgets('Add crumb for MaterialButton', (tester) async {
2537
await tester.runAsync(() async {
2638
final sut = fixture.getSut();

0 commit comments

Comments
 (0)