在flutter当中锁定屏幕是一个很常见的操作。
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'HomePage.dart';
void main()async {
WidgetsFlutterBinding.ensureInitialized(); //这句一定要有,要不然会报错
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);//DeviceOrientation有四个实例,代表四个方向。结合英文意思,这是设置首选方向
//所以说是可以设置多个的
runApp(MaterialApp(
home: Scaffold(body: Center(child: HomePage(),),),
)
);
}
标签:dart,DeviceOrientation,import,屏幕,锁定,HomePage,flutter
From: https://www.cnblogs.com/panzewen/p/18142922