Flutter 導航欄AppBar
恢弘志士之氣,不宜妄自菲薄。——諸葛亮
People of noble ambition should not belittle themselves. zhugeliang
以上效果是谷歌團隊建立的AppBar最初版,經典呀!!!
[知乎]聽 Flutter 創始人 Eric 為你講述 Flutter 的故事
AppBar
App 應用
Bar 條
簡稱 應用導航條
final Widget title 標題 app_bar.png
AppBar(title: Text('AppBarTitle'),)
final bool centerTitle 標題居中 app_bar.png
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.lightBlue, centerTitle: true, )
final Color backgroundColor 背景顏色 app_bar.png
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.red, )
final List<Widget> actions Widget集合 app_bar.png
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.green, actions: <Widget>[ IconButton(icon: const Icon(Icons.add),), IconButton(icon: const Icon(Icons.clear),), IconButton(icon: const Icon(Icons.arrow_drop_down),), ], )
final double elevation 陰影大小(Z軸方向) app_bar.png
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.red, actions: <Widget>[ IconButton(icon: const Icon(Icons.add),), IconButton(icon: const Icon(Icons.clear),), IconButton(icon: const Icon(Icons.arrow_drop_down),), ], elevation: 50, )
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.red, actions: <Widget>[ IconButton(icon: const Icon(Icons.add),), IconButton(icon: const Icon(Icons.clear),), IconButton(icon: const Icon(Icons.arrow_drop_down),), ], elevation: 0, )
final ShapeBorder shape 邊框形狀 app_bar.png
/ 圓角/
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.greenAccent, elevation: 4, shape: RoundedRectangleBorder( side: BorderSide.none, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(50.0), bottomRight: Radius.circular(30.0))), actions: <Widget>[ IconButton( icon: const Icon(Icons.add), ), IconButton( icon: const Icon(Icons.clear), ), IconButton( icon: const Icon(Icons.arrow_drop_down), ), ], )
/斜角/
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.greenAccent, elevation: 4, shape: BeveledRectangleBorder( side: BorderSide.none, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(20.0), bottomRight: Radius.circular(20.0))), actions: <Widget>[ IconButton( icon: const Icon(Icons.add), ), IconButton( icon: const Icon(Icons.clear), ), IconButton( icon: const Icon(Icons.arrow_drop_down), ), ], )
final PreferredSizeWidget bottom 底部widgetapp_bar.png
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.lightBlue, elevation: 4, actions: <Widget>[ IconButton( icon: const Icon(Icons.add), ), IconButton( icon: const Icon(Icons.clear), ), IconButton( icon: const Icon(Icons.arrow_drop_down), ), ], centerTitle: true, bottom: PreferredSize(child: Text('AppBarBottom')), )
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.lightBlue, elevation: 4, actions: <Widget>[ IconButton( icon: const Icon(Icons.add), ), IconButton( icon: const Icon(Icons.clear), ), IconButton( icon: const Icon(Icons.arrow_drop_down), ), ], centerTitle: true, bottom: PreferredSize(child: Text('AppBarBottom'),preferredSize: Size.fromHeight(100.0)) )
final Widget flexibleSpace 彈性空間app_bar.png
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.lightBlue, elevation: 4, actions: <Widget>[ IconButton( icon: const Icon(Icons.add), ), IconButton( icon: const Icon(Icons.clear), ), IconButton( icon: const Icon(Icons.arrow_drop_down), ), ], centerTitle: true, flexibleSpace: FlexibleSpaceBar( centerTitle: true, title: const Text('Flight Report'), ), bottom: PreferredSize(child: Text('AppBarBottom'), preferredSize: Size.fromHeight(50.0)))
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.lightBlue, elevation: 4, actions: <Widget>[ IconButton( icon: const Icon(Icons.add), ), IconButton( icon: const Icon(Icons.clear), ), IconButton( icon: const Icon(Icons.arrow_drop_down), ), ], centerTitle: true, flexibleSpace: FlexibleSpaceBar( centerTitle: true, title: const Text('Flight Report'), ), bottom: PreferredSize(child: Text('AppBarBottom'),preferredSize: Size.fromHeight(200.0)))
final Widget leading 靠前widget
AppBar( title: Text('AppBarTitle'), backgroundColor: Colors.lightBlue, leading: Builder(builder: (BuildContext context){ return IconButton(icon: Icon(Icons.menu), onPressed: null); },), elevation: 4, actions: <Widget>[ IconButton( icon: const Icon(Icons.add), ), IconButton( icon: const Icon(Icons.clear), ), IconButton( icon: const Icon(Icons.arrow_drop_down), ), ], centerTitle: true, flexibleSpace: FlexibleSpaceBar( centerTitle: true, title: const Text('Flight Report'), ), bottom: PreferredSize(child: Text('AppBarBottom'),preferredSize: Size.fromHeight(100.0))),
App導航欄懸浮 app_bar_pinned.mp4 app_bar.mp4
class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( body: CustomScrollView( physics: const BouncingScrollPhysics(), slivers: <Widget>[ SliverAppBar( stretch: false, onStretchTrigger: () { // Function callback for stretch return; }, pinned: true, expandedHeight: 300.0, flexibleSpace: FlexibleSpaceBar( stretchModes: <StretchMode>[ StretchMode.zoomBackground, StretchMode.blurBackground, StretchMode.fadeTitle, ], centerTitle: true, title: const Text('Flight Report'), background: Stack( fit: StackFit.expand, children: [ Image.network( 'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg', fit: BoxFit.cover, ), const DecoratedBox( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment(0.0, 0.5), end: Alignment(0.0, 0.0), colors: <Color>[ Color(0x60000000), Color(0x00000000), ], ), ), ), ], ), ), ), SliverList( delegate: SliverChildListDelegate([ ListTile( leading: Icon(Icons.wb_sunny), title: Text('Sunday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Sunday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Sunday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Sunday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Sunday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), ListTile( leading: Icon(Icons.wb_sunny), title: Text('Monday'), subtitle: Text('sunny, h: 80, l: 65'), ), // ListTiles++ ]), ), ], ), ); } }
參考:
相關文章
- flutter佈局-9-appbar導航欄和狀態列FlutterAPP
- 短視訊平臺原始碼,透明導航欄 AppBar原始碼APP
- Flutter仿閒魚底部導航欄實現Flutter
- flutter全屏沉浸式狀態列+標題欄|flutter凸起Tabbar導航FluttertabBar
- 在 Flutter 中實現一個浮動導航欄Flutter
- flutter 自定義tab導航-頂部導航-底部導航Flutter
- WordPresscategory導航欄Go
- Flutter路由和導航Flutter路由
- Flutter 導航設定Flutter
- Flutter 的路由導航Flutter路由
- qml 導航欄TabBar 工具欄ToolBartabBar
- 直播系統程式碼,flutter手寫一個底部導航欄Flutter
- GitHub 導航欄加強Github
- HTML橫向導航欄HTML
- Tablayout實現導航欄TabLayout
- iOS 導航欄的控制iOS
- bootstrap導航欄學習boot
- Flutter 底部導航詳解Flutter
- Flutter控制元件--AppBarFlutter控制元件APP
- uniapp自定義導航欄APP
- Flutter 最好的導航外掛Flutter
- 微信小程式自定義導航欄微信小程式
- CSS導航欄及下拉選單CSS
- ios自定義簡約導航欄iOS
- CSS 導航欄元素居中顯示CSS
- 常用元件 / 導航欄及圖示元件
- iOS導航欄佈局相關iOS
- flutter系列之:在flutter中使用導航NavigatorFlutter
- Flutter開發之路由與導航Flutter路由
- flutter小記之路由和導航Flutter路由
- 用 Flutter 搭建標籤+導航框架Flutter框架
- 直播系統平臺原始碼隱藏虛擬導航欄,禁止下拉通知欄,禁止上滑出虛擬導航欄原始碼
- Flutter深入淺出元件篇---AppBarFlutter元件APP
- [譯] 如何用 Flutter 來建立一個帶有底部導航欄的應用程式Flutter
- weex沉浸式導航欄解決方案
- jQuery實現吸頂動畫導航欄jQuery動畫
- CARDS主題 & 導航欄樣式修改
- uniapp更改導航欄按鈕文字APP