Fork me on GitHub

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(); }

 

posted @ 2019-10-07 11:10  Something_Diffrent  阅读(908)  评论(0编辑  收藏  举报