問題のライブラリはこちら
https://pub.dev/packages/workmanager
The callbackDispatcher needs to be either a static function or a top level function to be accessible as a Flutter entry point.
この公式の指示に従ってstaticでcallbackDispatcherを宣言したらこんなエラーが・・・
E/flutter ( 2580): [ERROR:flutter/shell/common/shell.cc(103)] Dart Unhandled Exception: NoSuchMethodError: No top-level getter 'callbackDispatcher' declared.
E/flutter ( 2580): Receiver: top-level
E/flutter ( 2580): Tried calling: callbackDispatcher, stack trace: #0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:214:5)
E/flutter ( 2580):
E/flutter ( 2580): [ERROR:flutter/runtime/dart_isolate.cc(713)] Could not resolve main entrypoint function.
E/flutter ( 2580): [ERROR:flutter/runtime/dart_isolate.cc(192)] Could not run the run main Dart entrypoint.
E/flutter ( 2580): [ERROR:flutter/runtime/runtime_controller.cc(415)] Could not create root isolate.
E/flutter ( 2580): [ERROR:flutter/shell/common/shell.cc(588)] Could not launch engine with configuration.
結論
トップレベルに宣言すれば治ります。
検証環境
Flutter 2.2.3
Dart 2.13.4
Workmanager 0.4.1
Kotlin 1.4.32