Closed ArunEdathadan closed 4 years ago
I see an error and blank screen in the Chrome browser and on android too, my flutter is v1.10.14 dev:
Exception has occurred. FlutterError (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 theWidgetsFlutterBinding.ensureInitialized()
first. If you're running a test, you can call theTestWidgetsFlutterBinding.ensureInitialized()
as the first line in your test'smain()
method to initialize the binding.)
Just added the code WidgetsFlutterBinding.ensureInitialized();
to main():
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown])
.then((_) => runApp(new MyApp()));
// runApp(new MyApp());
}
When running - build creates a blank app in android phone apk