initialize static method
Initializes TaskFlow.
Call this once in main() before runApp().
Optionally pass a dispatcher function (top-level, annotated with
@pragma('vm:entry-point')) to handle background task execution when
the app is not in foreground.
Example:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
TaskFlow.registerHandler('syncData', (ctx) async {
return TaskResult.success();
});
await TaskFlow.initialize();
runApp(MyApp());
}
Implementation
static Future<void> initialize({
TaskFlowDispatcher? dispatcher,
}) async {
_initialized = true;
await TaskFlowPlatform.instance.initialize();
}