Android 键盘导致状态栏重新出现
Android Keyboard causes Status Bar to reappear
我需要在我的应用程序中隐藏 Android 状态栏,所以我使用以下代码
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
main() {
SystemChrome.setEnabledSystemUIOverlays([]);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(child: TextField()), backgroundColor: Colors.orange));
}
}
我在屏幕上有一个 textfield
,所以只要 Android 键盘打开,状态栏就会重新出现。
我尝试了多个 Android 设备,但我遇到了同样的错误。
这真的是框架中的错误还是我做错了什么?
我在下面附上了一个简短的视频 link 来展示这个错误
https://drive.google.com/file/d/19qs5Rsrfc_G1oN5kbxgKvYQAXpTr8RZx/view?usp=sharing
我还没有在 iOS
测试过
请分享一些代码。我尝试在 initState()
中添加 SystemChrome.setEnabledSystemUIOverlays([]);
并且我有一个文本字段,它工作正常。
我所做的是在显示键盘后,延迟 2 秒(文档说是一秒)然后再次调用 setEnabledSystemUIOverlays
。
Future.delayed(Duration(seconds: 2)).then((value) => SystemChrome.setEnabledSystemUIOverlays([]));
根据:https://api.flutter.dev/flutter/services/SystemChrome/setEnabledSystemUIOverlays.html
when the keyboard becomes visible, it will enable the navigation bar and status bar system UI overlays. When the keyboard is closed, Android will not restore the previous UI visibility settings, and the UI visibility cannot be changed until 1 second after the keyboard is closed to prevent malware locking users from navigation buttons.
To regain "fullscreen" after text entry, the UI overlays should be set again after a delay of 1 second. This can be achieved through restoreSystemUIOverlays or calling this again. Otherwise, the original UI overlay settings will be automatically restored only when the application loses and regains focus.
我需要在我的应用程序中隐藏 Android 状态栏,所以我使用以下代码
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
main() {
SystemChrome.setEnabledSystemUIOverlays([]);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(child: TextField()), backgroundColor: Colors.orange));
}
}
我在屏幕上有一个 textfield
,所以只要 Android 键盘打开,状态栏就会重新出现。
我尝试了多个 Android 设备,但我遇到了同样的错误。
这真的是框架中的错误还是我做错了什么?
我在下面附上了一个简短的视频 link 来展示这个错误
https://drive.google.com/file/d/19qs5Rsrfc_G1oN5kbxgKvYQAXpTr8RZx/view?usp=sharing
我还没有在 iOS
请分享一些代码。我尝试在 initState()
中添加 SystemChrome.setEnabledSystemUIOverlays([]);
并且我有一个文本字段,它工作正常。
我所做的是在显示键盘后,延迟 2 秒(文档说是一秒)然后再次调用 setEnabledSystemUIOverlays
。
Future.delayed(Duration(seconds: 2)).then((value) => SystemChrome.setEnabledSystemUIOverlays([]));
根据:https://api.flutter.dev/flutter/services/SystemChrome/setEnabledSystemUIOverlays.html
when the keyboard becomes visible, it will enable the navigation bar and status bar system UI overlays. When the keyboard is closed, Android will not restore the previous UI visibility settings, and the UI visibility cannot be changed until 1 second after the keyboard is closed to prevent malware locking users from navigation buttons.
To regain "fullscreen" after text entry, the UI overlays should be set again after a delay of 1 second. This can be achieved through restoreSystemUIOverlays or calling this again. Otherwise, the original UI overlay settings will be automatically restored only when the application loses and regains focus.