call method

  1. @override
FutureOr<void> call(
  1. Hub hub,
  2. SentryFlutterOptions options
)
override

A Callable method for the Integration interface

Implementation

@override
FutureOr<void> call(Hub hub, SentryFlutterOptions options) {
  _observer = SentryWidgetsBindingObserver(
    hub: hub,
    options: options,
  );

  // We don't need to call `WidgetsFlutterBinding.ensureInitialized()`
  // because `WidgetsFlutterBindingIntegration` already calls it.
  // If the instance is not created, we skip it to keep going.
  final instance = WidgetsBinding.instance;
  if (instance != null) {
    instance.addObserver(_observer!);
    options.sdk.addIntegration('widgetsBindingIntegration');
  } else {
    options.logger(
      SentryLevel.error,
      'widgetsBindingIntegration failed to be installed',
    );
  }
}