Flutter控制屏幕旋转

/// 初始化时设置为只能竖屏
@override void initState() { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown ]); super.initState(); }
/// 退出时还原四个方向
dispose(){ SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, ]);
super.dispose(); }
原文地址:https://www.cnblogs.com/hepeng/p/11629762.html