在main.dart中添加如下代码

    1. void main() {
    2. // 强制横屏
    3. WidgetsFlutterBinding.ensureInitialized();
    4. SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]).then((onVal) {
    5. runApp(MyApp());
    6. });
    7. }