Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Binding has not yet been initialized #9

Closed
Alex-Alive opened this issue Mar 8, 2023 · 1 comment
Closed

[BUG]Binding has not yet been initialized #9

Alex-Alive opened this issue Mar 8, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Alex-Alive
Copy link

Alex-Alive commented Mar 8, 2023

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Binding has not yet been initialized.
The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After calling that method, the "instance" getter will return the binding.
In a test, one can call "TestWidgetsFlutterBinding.ensureInitialized()" as the first line in the test's "main()" method to initialize the binding.
If ServicesBinding is a custom binding mixin, there must also be a custom binding class, like WidgetsFlutterBinding, but that mixes in the selected binding, and that is the class that must be constructed before using the "instance" getter.
#0      BindingBase.checkInstance.<anonymous closure> (package:flutter/src/foundation/binding.dart:287:9)
#1      BindingBase.checkInstance (package:flutter/src/foundation/binding.dart:369:6)
#2      ServicesBinding.instance (package:flutter/src/services/binding.dart:55:54)
#3      _findBinaryMessenger (package:flutter/src/services/platform_channel.dart:136:25)
#4      BasicMessageChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:183:56)
#5      BasicMessageChannel.send (package:flutter/src/services/platform_channel.dart:197:38)
#6      UserDefaultsApi.getAll (package:shared_preferences_foundation/messages.g.dart:115:52)
#7      SharedPreferencesFoundation.getAll (package:shared_preferences_foundation/shared_preferences_foundation.dart:46:53)
#8      SharedPreferences._getSharedPreferencesMap (package:shared_preferences/shared_preferences.dart:164:57)
#9      SharedPreferences.getInstance (package:shared_preferences/shared_preferences.dart:33:19)
#10     AppManager.initAppData (package:chat_desk/core/io/app_manager.dart:7:43)
#11     main (package:chat_desk/main.dart:27:20)
#12     _runMain.<anonymous closure> (dart:ui/hooks.dart:131:23)
#13     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#14     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

Using the MacBook M1 chip
Flutter 3.7.6 version
An error occurs when running on a MacOS system

@omegaui omegaui added the bug Something isn't working label Mar 8, 2023
@omegaui omegaui self-assigned this Mar 8, 2023
@omegaui omegaui added this to the version 1.0 - stable milestone Mar 8, 2023
@omegaui omegaui closed this as completed in 53ac501 Mar 8, 2023
@omegaui
Copy link
Owner

omegaui commented Mar 8, 2023

@Alex-Alive
The recent commit should resolve this issue, if not you may reopen this issue!
More Bugs are likely to encounter cause' this is in the phase of development.
Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants