天天看點

flutter - 強制橫屏/豎屏

flutter 強制豎屏

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

flutter 強制橫屏

void main() {
      SystemChrome.setPreferredOrientations(
               [DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight])
          .then((_) {
        runApp(MyApp());
      });
    }