Cop*_*oad 64
setEnabledSystemUIMode(推荐):全屏(带恢复):
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
Run Code Online (Sandbox Code Playgroud)
全屏(无需恢复):
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
Run Code Online (Sandbox Code Playgroud)
显示特定的叠加层:
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual,
overlays: [
SystemUiOverlay.top, // Shows Status bar and hides Navigation bar
],
);
Run Code Online (Sandbox Code Playgroud)
退出全屏:
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
Run Code Online (Sandbox Code Playgroud)
恢复:状态栏和导航栏出现后,将再次隐藏。
Rém*_*let 40
这与Android状态栏完全相同.这样做SystemChrome.setEnabledSystemUIOverlays([])皮两种状态栏和导航栏.
Jaw*_*wad 12
// to hide only bottom bar:
SystemChrome.setEnabledSystemUIOverlays ([SystemUiOverlay.top]);
// to hide only status bar:
SystemChrome.setEnabledSystemUIOverlays ([SystemUiOverlay.bottom]);
// to hide both:
SystemChrome.setEnabledSystemUIOverlays ([]);
Run Code Online (Sandbox Code Playgroud)
Sol*_*f93 11
最后,我找到了一种方法来设置一个全屏类。并禁用其他课程。
要设置全屏,请将此代码放入initState()
SystemChrome.setEnabledSystemUIOverlays([]);
并恢复正常。在处置()
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
在同一个班。
@override
void dispose() {
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
super.dispose();
}
@override
initState() {
SystemChrome.setEnabledSystemUIOverlays([]);
super.initState();
}
Run Code Online (Sandbox Code Playgroud)
你不能设置
SystemChrome.restoreSystemUIOverlays();
Run Code Online (Sandbox Code Playgroud)
在dispose() 中。因为它已经在说
**Restores the system overlays to the last settings provided via [setEnabledSystemUIOverlays].**
May be used when the platform force enables/disables UI elements.
For example, when the Android keyboard disables hidden status and navigation bars,
this can be called to re-disable the bars when the keyboard is closed.
On Android, the system UI cannot be changed until 1 second after the previous
change. This is to prevent malware from permanently hiding navigation buttons.`
Run Code Online (Sandbox Code Playgroud)
下面的代码非常适合全屏
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
Run Code Online (Sandbox Code Playgroud)
import 'package:flutter/services.dart';
////
@override
Widget build(BuildContext context) {
///Set color status bar
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'images/ic_splash_logo.png',
width: 97.0,
height: 115.0,
fit: BoxFit.contain,
),
SizedBox(
height: 10.0,
),
Text(
'iComplain',
style: TextStyle(fontSize: 24,
color: Color(0xFF174D73),
fontFamily: 'Helvetica'
),
),
],
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
小智 6
SystemChrome.setEnabledSystemUIOverlays([]);
这会隐藏顶部和底部栏,但应用程序大小保持不变。它不会扩展到全屏高度。
更新:
在无状态或有状态小部件的 flutter 应用程序中启用全屏
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
Run Code Online (Sandbox Code Playgroud)
退出全屏模式
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
Run Code Online (Sandbox Code Playgroud)
例子
@override
void initState() {
// Start full screen
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
super.initState();
}
@override
void dispose() {
super.dispose();
// Exit full screen
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12623 次 |
| 最近记录: |