[Flutter] 플로팅 버튼 중단부에 위치시키기 BottomApp, Floationg Action
반응형
이런걸 만들어보자.
int _selectedIndex = 0;
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
Scaffold(
bottomNavigationBar: BottomAppBar(
shape: CircularNotchedRectangle(),
child: Container(
height: 60.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(
icon: Icon(Icons.home),
onPressed: () => _onItemTapped(0),
color: _selectedIndex == 0
? Theme.of(context).primaryColor
: Colors.grey,
),
IconButton(
icon: Icon(Icons.favorite),
onPressed: () => _onItemTapped(1),
color: _selectedIndex == 1
? Theme.of(context).primaryColor
: Colors.grey,
),
IconButton(
icon: Icon(Icons.person),
onPressed: () => _onItemTapped(2),
color: _selectedIndex == 2
? Theme.of(context).primaryColor
: Colors.grey,
),
IconButton(
icon: Icon(Icons.settings),
onPressed: () => _onItemTapped(3),
color: _selectedIndex == 3
? Theme.of(context).primaryColor
: Colors.grey,
),
],
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your onPressed code here!
},
child: const Icon(Icons.add),
elevation: 0,
),
// appBar: AppBar(
// backgroundColor: FNC_GREY,
// title: TextButton(onPressed: () {}, child: Text('FNC AERATOR')),
// centerTitle: true,
// actions: [
// IconButton(onPressed: () {}, icon: Icon(Icons.menu_rounded)),
// ],
// ),
body: Text('Home'));
반응형
'Study > Flutter' 카테고리의 다른 글
[Flutter] 플로팅버튼 스피드다이얼로 만들기. (0) | 2023.02.22 |
---|---|
[Flutter] GestureDetector Widget (0) | 2023.02.03 |
[Flutter] Button 종류 변경 (0) | 2023.02.02 |
[Flutter] Sqlite를 구현하는 Drift (0) | 2023.01.30 |
[Flutter] Widget을 밀어서 삭제하는 Dismissible (0) | 2023.01.27 |
댓글