initializeWorker function
Initializes the plugin by registering a worker
callback.
All background work will be dispatched to the worker
function,
which will run in a headless isolate.
You may assign different tasks to other functions according to the WorkPayload of each work. For example:
Future<void> worker(WorkPayload payload) {
final id = payload.tags.first;
switch (id) {
case 'task1':
return onTask1();
default:
return Future.value();
}
}
...
initializeWorker(worker);
Implementation
Future<void> initializeWorker(WorkerFn worker) =>
apiChannel.invokeMethod(
'$METHOD_PREFIX#initialize',
[
ensureRawHandle(callbackDispatcher),
ensureRawHandle(worker),
]);