Flutter Update WidgetsFlutterBinding
I found the solution online:
Just put this row on the top of the main function:
WidgetsFlutterBinding.ensureInitialized();
user2244131
Hi, I'm a maths teacher and used to be a java developer. My aim is to develop a maths application that teaches how to understand any maths topic. To begin with I'm starting with factors and then will extend this over many years. I hope I can help others as well as others helping me to understand android. In my past I developed SQL Server databases, java, C++, VB etc My knowledge of java is good, but my knowledge of android is poor, at present. Thanks to all who help, what comes round, goes round.
Updated on December 16, 2022Comments
-
user2244131 over 1 year
before the Flutter update today my app ran OK, now get: 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 theWidgetsFlutterBinding.ensureInitialized()
first.Any ideas? E/flutter (29270): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
I am using : import 'package:get_it/get_it.dart';
void main() async { await di.init(); runApp(MyApp()); }
Where di.init() initialises the bloc
-
user2244131 over 4 yearsThanks and this worked first time. A good example of being a member of Stack Overflow
-
msayubi76 almost 4 yearsthis very first line of main() but not working.any update on this??
-
John Joe over 2 years@msayubi76 same here