web-dev-qa-db-ja.com

Flutter:未処理の例外:バインディングが初期化される前にServicesBinding.defaultBinaryMessengerにアクセスしました

この問題を解決する解決策はありますか?

Stacktrace:

[VERBOSE-2:ui_Dart_state.cc(148)] Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first.
If you're running a test, you can call the `TestWidgetsFlutterBinding.ensureInitialized()` as the first line in your test's `main()` method to initialize the binding.
#0      defaultBinaryMessenger.<anonymous closure> (package:flutter/src/services/binary_messenger.Dart:73:7)
#1      defaultBinaryMessenger (package:flutter/src/services/binary_messenger.Dart:86:4)
#2      MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.Dart:140:62)
#3      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.Dart:314:35)
<asynchronous suspension>
#4      MethodChannel.invokeMapMethod (package:f<…>
91

GitHub問題47033に投稿された回答で問題が解決しました。

問題: https://github.com/flutter/flutter/issues/470

私のために働いた解決策: https://github.com/flutter/flutter/issues/47033#issuecomment-571936089

これはフラッターバージョン1.12.13 + hotfixに関する問題だと思います。フラッターのダウングレードも役立つ可能性があります。

0
Achintha Isuru