Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
make _observer nullable, since call may not be called
  • Loading branch information
fzyzcjy committed Mar 6, 2021
commit ad057737fb9bdc30b18561d51797ea1a24865f17
8 changes: 4 additions & 4 deletions flutter/lib/src/default_integrations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class NativeSdkIntegration extends Integration<SentryFlutterOptions> {
/// - [SentryWidgetsBindingObserver]
/// - [WidgetsBindingObserver](https://api.flutter.dev/flutter/widgets/WidgetsBindingObserver-class.html)
class WidgetsBindingIntegration extends Integration<SentryFlutterOptions> {
late SentryWidgetsBindingObserver _observer;
SentryWidgetsBindingObserver? _observer;

@override
FutureOr<void> call(Hub hub, SentryFlutterOptions options) {
Expand All @@ -215,7 +215,7 @@ class WidgetsBindingIntegration extends Integration<SentryFlutterOptions> {
// If the instance is not created, we skip it to keep going.
final instance = WidgetsBinding.instance;
if (instance != null) {
instance.addObserver(_observer);
instance.addObserver(_observer!);
options.sdk.addIntegration('widgetsBindingIntegration');
} else {
options.logger(
Expand All @@ -228,8 +228,8 @@ class WidgetsBindingIntegration extends Integration<SentryFlutterOptions> {
@override
void close() {
final instance = WidgetsBinding.instance;
if (instance != null) {
instance.removeObserver(_observer);
if (instance != null && _observer != null) {
instance.removeObserver(_observer!);
}
}
}
Expand Down