AppLifecycleListener constructor

AppLifecycleListener({
  1. WidgetsBinding? binding,
  2. VoidCallback? onResume,
  3. VoidCallback? onInactive,
  4. VoidCallback? onHide,
  5. VoidCallback? onShow,
  6. VoidCallback? onPause,
  7. VoidCallback? onRestart,
  8. VoidCallback? onDetach,
  9. AppExitRequestCallback? onExitRequested,
  10. ValueChanged<AppLifecycleState>? onStateChange,
})

Creates an AppLifecycleListener.

Implementation

AppLifecycleListener({
  WidgetsBinding? binding,
  this.onResume,
  this.onInactive,
  this.onHide,
  this.onShow,
  this.onPause,
  this.onRestart,
  this.onDetach,
  this.onExitRequested,
  this.onStateChange,
})  : binding = binding ?? WidgetsBinding.instance,
      _lifecycleState = (binding ?? WidgetsBinding.instance).lifecycleState {
  // TODO(polina-c): stop duplicating code across disposables
  // https://github.com/flutter/flutter/issues/137435
  if (kFlutterMemoryAllocationsEnabled) {
    FlutterMemoryAllocations.instance.dispatchObjectCreated(
      library: 'package:flutter/widgets.dart',
      className: '$AppLifecycleListener',
      object: this,
    );
  }
  this.binding.addObserver(this);
}