-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbottomnavigationbar.dart
44 lines (39 loc) · 1.13 KB
/
bottomnavigationbar.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import 'package:flutter/material.dart';
class BottomNavigationBarWidget extends StatefulWidget {
const BottomNavigationBarWidget({super.key});
@override
State<BottomNavigationBarWidget> createState() =>
_BottomNavigationBarWidgetState();
}
class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
int _currentIndex = 0;
List<Widget> body = const [
Icon(Icons.home),
Icon(Icons.menu),
Icon(Icons.person),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("BottomNavigationBar"),
),
body: Center(
child: body[_currentIndex],
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(icon: Icon(Icons.menu), label: 'Menu'),
BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Person')
],
onTap: ((value) {
setState(() {
_currentIndex = value;
});
}),
),
);
}
}