更新时间:2023-11-30 10:58:10
强制启用
导入软件包:main.dart
文件中的import 'package:flutter/services.dart';
Import package: import 'package:flutter/services.dart';
in main.dart
file
1.横向模式:
// Set landscape orientation
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
2.纵向模式:
// Set portrait orientation
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitDown,
DeviceOrientation.portraitUp,
]);