mitesh77 / Best-Flutter-UI-Templates

completely free for everyone. Its build-in Flutter Dart.
Other
20.2k stars 4.51k forks source link

When running - build creates a blank app in android phone apk #18

Closed ArunEdathadan closed 4 years ago

ArunEdathadan commented 4 years ago

When running - build creates a blank app in android phone apk

igkvl commented 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 the WidgetsFlutterBinding.ensureInitialized() first. 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.)

igkvl commented 4 years ago

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());
}