Skip to content

Conversation

@algodave
Copy link

On Flutter 1.9.5 I was getting the following error on await DotEnv().load('.env'):

ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.

After reproducing the error in a sample app Flutter gave me an explanatory error message with the solution:

E/flutter (19823): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
E/flutter (19823): 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.
E/flutter (19823): 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.

So I added WidgetsFlutterBinding.ensureInitialized() before calling rootBundle.loadString()

@java-james
Copy link
Owner

Thanks for the PR. Letting you know I've seen it and will review it with you before the end of the week.

@java-james java-james merged commit 6fdd9fc into java-james:master Sep 1, 2019
@java-james
Copy link
Owner

Merged, released, tagged & published to pub. Thanks for the contribution @algodave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants