void main() {
WidgetsFlutterBinding.ensureInitialized;
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(const MyApp());
}
I add this section to "main.dart" but it didn't work on Samsung Phone.
CodePudding user response:
setPreferredOrientation is async, i think the issue might be that the app run before setPreferredOrientation is finished. Try using the "then" function to run the app after the function is done. Like this :
WidgetsFlutterBinding.ensureInitialized;
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then(
(value) => runApp(const MyApp()));