Commit 3f77682b by tanghuan

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

1 parent cf112417
......@@ -9,28 +9,28 @@ class ScreenHandler extends MessageHandler {
}
int type = params['type'];
_setOrientation(type);
await _setOrientation(type);
return true;
}
void _setOrientation(int screenType) {
Future<void> _setOrientation(int screenType) async {
if (screenType == 2) {
// 横屏模式
SystemChrome.setPreferredOrientations([
await SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
// 隐藏状态栏
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
} else {
// 竖屏模式(默认)
SystemChrome.setPreferredOrientations([
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
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!