onSchedule static method
Subscribe to Config.schedule events.
Your callback
will be executed each time a Config.schedule event fires. Your callback
will be provided with the current State: state.enabled
will reflect the state according to your Config.schedule.
Example
BackgroundGeolocation.onSchedule((State state) {
if (state.enabled) {
print('[onSchedule] scheduled start tracking');
} else {
print('[onSchedule] scheduled stop tracking');
}
});
Implementation
static void onSchedule(Function(State) callback) {
if (_eventsSchedule == null) {
_eventsSchedule = _eventChannelSchedule
.receiveBroadcastStream()
.map((dynamic event) => State(event));
}
_registerSubscription(_eventsSchedule!.listen(callback), callback);
}