Flutter: how to prevent device orientation changes and force portrait?

前端 未结 18 1407
鱼传尺愫
鱼传尺愫 2020-12-04 05:41

I would like to prevent my application from changing its orientation and force the layout to stick to \"portrait\".

In the main.dart, I put:

void mai         


        
18条回答
  •  一整个雨季
    2020-12-04 06:32

    It's possible to enable the requires fullscreen option in iOS case.

    void main() async {
          WidgetsFlutterBinding.ensureInitialized();
          SystemChrome.setPreferredOrientations([
            DeviceOrientation.landscapeRight,
            DeviceOrientation.landscapeLeft,
          ]).then((_) {
            runApp(MediaQuery(
                data: MediaQueryData(),
                child:
                    MaterialApp(debugShowCheckedModeBanner: false, home: LoginPage())));
          });
        }
    

提交回复
热议问题