enqueue method
Schedule the chain for execution.
Submits the chain to the OS scheduler. The chain will execute according to the defined sequence and constraints.
Returns: ScheduleResult.accepted if successfully scheduled.
Throws: StateError if NativeWorkManager is not initialized.
final result = await NativeWorkManager.beginWith(taskA)
.then(taskB)
.enqueue();
if (result == ScheduleResult.accepted) {
print('Chain scheduled successfully');
}
Important: You MUST call this method to actually schedule the chain. Building the chain without calling enqueue() does nothing.
Implementation
Future<ScheduleResult> enqueue() async {
if (enqueueCallback == null) {
throw StateError(
'NativeWorkManager not initialized. '
'Call NativeWorkManager.initialize() first.',
);
}
return enqueueCallback!(this);
}