[Flutter/dart] ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialize
Overview
Suddenly the above error message appears and the app crashes. As in the error message and the article on the net, adding
WidgetsFlutterBinding.ensureInitialized();
at the top of main() doesn't solve the problem.
Cause and solution
It seems that the cause was accessing assets from another isolate. (reference)
As a solution, I used flutter_isolate and the above error disappeared.
Click here for how to use flutter_isolate
Lastly
(Added on 2021/2/20)
Since flutter_isolate creates a new dart execution environment in another isolate, it will not be recognized as "another isolate" and no error will occur (reference). However, flutter_isolate officially supports only some libraries such as notification, so it is at your own risk.
Recent Posts
See AllWhat want to do I want to create an input form using TextField. For example, if the input content is a monetary amount, I would like to...
What want to do There is a variable that remain unchanged once the initial value is determined. However, it cannot be determined yet when...
What want to do As the title suggests. Place two widgets in one line on the screen One in the center of the screen and the other on the...
Commentaires