欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Flutter 透明狀態(tài)欄及字體顏色的設(shè)置方法

 更新時(shí)間:2020年04月30日 10:54:03   作者:哇咔 哇咔  
這篇文章主要介紹了Flutter 透明狀態(tài)欄及字體顏色的設(shè)置方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

注:底色透明是否生效與android版本有關(guān),版本過低設(shè)置無效

1.在main.dart內(nèi)設(shè)置

void main(){
 runApp(new MyApp());
 if (Platform.isAndroid) {
 //設(shè)置Android頭部的導(dǎo)航欄透明
 SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
 	statusBarColor: Colors.transparent, //全局設(shè)置透明
 	statusBarIconBrightness: Brightness.light 
 	//light:黑色圖標(biāo) dark:白色圖標(biāo) 
 	//在此處設(shè)置statusBarIconBrightness為全局設(shè)置
 );
 SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
 }
}

2.單頁面設(shè)置

appBar: AppBar(
		  title: new Text(''),
	  elevation: 0,
	  brightness: Brightness.dark, //設(shè)置為白色字體
	  ),

注:設(shè)置AppBar之后,單獨(dú)在build內(nèi)設(shè)置這行代碼會(huì)失效 SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);

ps:下面看下Flutter修改狀態(tài)欄顏色以及字體顏色

Flutter沉浸式狀態(tài)欄

void main() {
 runApp(MyApp());
 if (Platform.isAndroid) {
 // 以下兩行 設(shè)置android狀態(tài)欄為透明的沉浸。寫在組件渲染之后,是為了在渲染后進(jìn)行set賦值,覆蓋狀態(tài)欄,寫在渲染之前MaterialApp組件會(huì)覆蓋掉這個(gè)值。
 SystemUiOverlayStyle systemUiOverlayStyle =
  SystemUiOverlayStyle(statusBarColor: Colors.transparent);
 SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
 }
}

Flutter修改狀態(tài)欄字體顏色

使用AnnotatedRegion包裹Scaffold,可以使得狀態(tài)欄顏色改變,有dark和light兩種

@override
 Widget build(BuildContext context) {

 return AnnotatedRegion<SystemUiOverlayStyle>(
  value: SystemUiOverlayStyle.light,
  child: Material(child:Scaffold(),),);
 }

到此這篇關(guān)于Flutter 透明狀態(tài)欄及字體顏色的文章就介紹到這了,更多相關(guān)Flutter 狀態(tài)欄字體顏色內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論