0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

FlutterのWorkManagerのcallbackDispatcherをstaticで宣言するとエラーになる

Last updated at Posted at 2021-08-15

問題のライブラリはこちら
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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?