回答編集履歴
1
情報の追加
test
CHANGED
@@ -9,3 +9,65 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
flutter fixed bottom navigation barで調べたらたくさん出てくると思います。
|
12
|
+
|
13
|
+
またgetXなど状態管理のライブラリを使っても書くことができます。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
getXを使ったbottomnavigationbarの例
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
home.dart
|
22
|
+
|
23
|
+
```dart
|
24
|
+
|
25
|
+
stl
|
26
|
+
|
27
|
+
final NavController _navController = Get.put(NavController());
|
28
|
+
|
29
|
+
bottomNavigationBar: GetBuilder<NavController>(builder: (_)
|
30
|
+
|
31
|
+
=>BottomNavigationBar(
|
32
|
+
|
33
|
+
items: [
|
34
|
+
|
35
|
+
BottomNavigationBarItem(icon: Icon(Icons.home), label: "ホーム"),
|
36
|
+
|
37
|
+
BottomNavigationBarItem(icon: Icon(Icons.web), label: "ウェブ"),
|
38
|
+
|
39
|
+
BottomNavigationBarItem(icon: Icon(Icons.share), label: "シェア"),
|
40
|
+
|
41
|
+
],
|
42
|
+
|
43
|
+
currentIndex: _navController.selectedIndex,
|
44
|
+
|
45
|
+
onTap: _navController.navTap,
|
46
|
+
|
47
|
+
),
|
48
|
+
|
49
|
+
),
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
navController.dart
|
54
|
+
|
55
|
+
```dart
|
56
|
+
|
57
|
+
class NavController extends GetxController{
|
58
|
+
|
59
|
+
int selectedIndex = 0;
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
void navTap(int value) {
|
64
|
+
|
65
|
+
selectedIndex = value;
|
66
|
+
|
67
|
+
update();
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
```
|