Commit 3f77682b by tanghuan

setScreen指令,等待实际处理完成之后再返回结果

1 parent cf112417
...@@ -9,28 +9,28 @@ class ScreenHandler extends MessageHandler { ...@@ -9,28 +9,28 @@ class ScreenHandler extends MessageHandler {
} }
int type = params['type']; int type = params['type'];
_setOrientation(type); await _setOrientation(type);
return true; return true;
} }
void _setOrientation(int screenType) { Future<void> _setOrientation(int screenType) async {
if (screenType == 2) { if (screenType == 2) {
// 横屏模式 // 横屏模式
SystemChrome.setPreferredOrientations([ await SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight, DeviceOrientation.landscapeRight,
]); ]);
// 隐藏状态栏 // 隐藏状态栏
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive); await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
} else { } else {
// 竖屏模式(默认) // 竖屏模式(默认)
SystemChrome.setPreferredOrientations([ await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp, DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown, DeviceOrientation.portraitDown,
]); ]);
// 显示状态栏 // 显示状态栏
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
} }
} }
} }
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!