// add this, and it should be the first line in main method WidgetsFlutterBinding.ensureInitialized();