On my flutter app, I need the screen to be portrait mode only. Either portraitUp or portraitDown. So I added this code in the main file:
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
runApp(MyApp());
}
But when I tested this on an emulator. It only stays in portraitUp. Even when I switch the emulator to portraitDown. What's causing this and how do I fix this?