2022年12月21日 星期三

Flutter學習 -BottomAppBar組件

BottomAppBarFlutter導覽列於放置鈕一同使用AppBar

放置於bottomNavigationBar後的寫法
bottomNavigationBar: BottomAppBar(
//顏色
color: Colors.blue,
//用此可產生一個圓滑缺口
shape: CircularNotchedRectangle(),
//透過Row將四個IconButton放入
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(Icons.home),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.work),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.email),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.settings),
onPressed: () {},
),
],
),
),
配合floatingActionButton使用,可以在導覽列上產生特別的效果。寫法如下:
floatingActionButton: FloatingActionButton(
elevation: 4.0,
child: Icon(Icons.add),
onPressed: () {},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomAppBar(
//顏色
color: Colors.blue,
//用此可產生一個圓滑缺口
shape: CircularNotchedRectangle(),
//透過Row將四個IconButton放入
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(Icons.home),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.work),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.email),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.settings),
onPressed: () {},
),
],
),
),

如果要調整 FloatingActionButton的位置,可以用 FloatingActionButtonLocation屬性控制它的位置,FloatingActionButtonLocation
1. FloatingActionButtonLocation.centerDocked 2. FloatingActionButtonLocation.centerFloat 3. FloatingActionButtonLocation.endDocked 4. FloatingActionButtonLocation.endFloat 5. FloatingActionButtonLocation.endTop 6. FloatingActionButtonLocation.miniCenterDocked 7. FloatingActionButtonLocation.miniCenterFloat 8. FloatingActionButtonLocation.miniEndDocked 9. FloatingActionButtonLocation.miniEndFloat 10. FloatingActionButtonLocation.miniStartTop 11. FloatingActionButtonLocation.startTop


沒有留言:

張貼留言