enableLifecycle method
Enable per-channel lifecycle handling
When enabled, this channel listens to app lifecycle changes and applies the policy from ChannelLifecycleConfig. Defaults:
- Background (
inactive/paused/hidden): pause with fast fade - Foreground (
resumed): resume with gentle fade - Detached: no action
Only state changes initiated by the lifecycle are reversed on resume (we won’t resume something your game paused intentionally).
Implementation
void enableLifecycle([ChannelLifecycleConfig cfg = const ChannelLifecycleConfig()]) {
_lifecycleObserver ??= ChannelLifecycleObserver(this, cfg);
WidgetsBinding.instance.addObserver(_lifecycleObserver!);
}