initWidgetsBindingSignals function
Call this method in main to setup the signals to react to the WidgetsBinding instance
void main() {
...
initWidgetsBindingSignals();
runApp(...);
}
Then in your application you can react to the app lifecycle and accessibility focus signal.
effect(() {
print('current lifecycle: $appLifecycleSignal');
});
effect(() {
print("current accessibility focus: $accessibilityFocusSignal");
});
Implementation
void initWidgetsBindingSignals([WidgetsBinding? binding]) {
if (_setup) return;
_setup = true;
final widgetsBinding = binding ?? WidgetsBinding.instance;
final observer = AppLifecycleListener(onStateChange: appLifecycleSignal.set);
widgetsBinding.addObserver(observer);
}