Flutter: How to set and lock screen orientation on-demand

后端 未结 6 1408
南方客
南方客 2020-11-28 22:45

On one of my flutter pages, I need the screen to set to landscape mode and lock it so it can\'t rotate into portrait mode, but only on the one page. So need a way to enable

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 23:05

    void main() {
      WidgetsFlutterBinding.ensureInitialized();
      SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown])
        .then((_) {
          runApp(new MyApp());
        });
    }
    

提交回复
热议问题