initSchedulerBindingSignals function
Call this method in main to setup the signals to react to the SchedulerBinding instance
void main() {
...
initSchedulerBindingSignals();
runApp(...);
}
Then in your application you can react to the timings, onFrame and onScheduleFrame signals. This is useful for driving animation outside of widgets.
effect(() {
print('on persistent frame: $onPersistentFrameSignal');
});
effect(() {
print('on schedule frame: $onScheduleFrameSignal');
});
effect(() {
print('on timings: $timingsSignal');
});
Implementation
void initSchedulerBindingSignals([SchedulerBinding? binding]) {
if (_setup) return;
_setup = true;
final schedulerBinding = binding ?? SchedulerBinding.instance;
schedulerBinding
..addPersistentFrameCallback(onPersistentFrameSignal.set)
..addTimingsCallback(timingsSignal.set)
..scheduleFrameCallback(onScheduleFrameSignal.set, rescheduling: false);
}