SystemChrome
これは、フルスクリーンやステータスバーの設定など、アプリケーションのシステムレベルの動作を制御するために Flutter によって提供されるクラスです。
- ステータスバーを透明に設定する
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark, // 状态栏图标亮色
),
);
を使用して、ステータス バーの透明な背景と黒いアイコンsetSystemUIOverlayStyle
を設定します。
- ステータスバーのテキストの色を白に変更します
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.dark.copyWith(
statusBarIconBrightness: Brightness.light,
),
);
setSystemUIOverlayStyle
でステータスバーの文字色を白に変更します。
- 下部のナビゲーション バーを非表示にする
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
下部のナビゲーション バーをsetEnabledSystemUIOverlays
非表示にする、ステータス バーのみが表示されます。
- 横画面の禁止
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
画面の横向きをsetPreferredOrientations
無効にする、縦向きのみが許可されます。
- 全画面モードを設定する
SystemChrome.setEnabledSystemUIOverlays([]);
で全画面モードsetEnabledSystemUIOverlays
を設定する、ステータス バー、設定パネル、ナビゲーション バーが非表示になります。
- ステータスバーのハイライトモードを設定する
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle.light,
);
setSystemUIOverlayStyle
ステータスバーのアイコンとテキストを明るい色に設定します。
興味があれば、私の総合公式アカウント:bigleadに注目してください。