Skip to content

Fix SentryUserInteractionWidget throwing when Sentry is not enabled #1363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Fix `SentryUserInteractionWidget` throwing when Sentry is not enabled ([#1363](https://github.com/getsentry/sentry-dart/pull/1363))

## 7.3.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ class SentryUserInteractionWidget extends StatefulWidget {

SentryFlutterOptions? get _options =>
// ignore: invalid_use_of_internal_member
_hub.options as SentryFlutterOptions?;
_hub.options is SentryFlutterOptions
// ignore: invalid_use_of_internal_member
? _hub.options as SentryFlutterOptions
: null;

@override
StatefulElement createElement() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@TestOn('vm')

// ignore_for_file: invalid_use_of_internal_member

import 'dart:async';
Expand All @@ -14,13 +13,26 @@ import '../mocks.dart';
import '../mocks.mocks.dart';

void main() {
group('$SentryUserInteractionWidget crumbs', () {
late Fixture fixture;
setUp(() async {
fixture = Fixture();
TestWidgetsFlutterBinding.ensureInitialized();
});
late Fixture fixture;
setUp(() async {
fixture = Fixture();
TestWidgetsFlutterBinding.ensureInitialized();
});

testWidgets(
'$SentryUserInteractionWidget does not throw cast exception when Sentry is disabled',
(tester) async {
await tester.runAsync(() async {
await tester.pumpWidget(
SentryUserInteractionWidget(
child: MaterialApp(),
),
);
});
},
);

group('$SentryUserInteractionWidget crumbs', () {
testWidgets('Add crumb for MaterialButton', (tester) async {
await tester.runAsync(() async {
final sut = fixture.getSut();
Expand Down