getAppWrapper method

ObservabilityWidgetWrapper? getAppWrapper()

Returns a widget wrapper function if the active observability provider supports it (e.g. Sentry's SentryWidget for screenshot capture).

Returns null if the provider does not require a wrapper or if the ObservabilityService has not been registered yet.

This method is safe to call from within the appRunner callback (before initialise has fully completed) since it relies on core.isRegistered rather than _isInitialised.

Usage:

final wrapper = LittlefishObservabilityManager.instance.getAppWrapper();
runApp(wrapper != null ? wrapper(MyApp()) : MyApp());

Implementation

ObservabilityWidgetWrapper? getAppWrapper() {
  if (core.isRegistered<ObservabilityService>()) {
    return core.get<ObservabilityService>().getAppWrapper();
  }
  return null;
}