AppLifecycleListener constructor
- WidgetsBinding? binding,
- VoidCallback? onResume,
- VoidCallback? onInactive,
- VoidCallback? onHide,
- VoidCallback? onShow,
- VoidCallback? onPause,
- VoidCallback? onRestart,
- VoidCallback? onDetach,
- AppExitRequestCallback? onExitRequested,
- 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);
}