質問編集履歴
1
ご指摘いただいたdefaultの追加と、不足していたmain.dartとmenu, profileのソースを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,6 +9,43 @@
|
|
9
9
|
|
10
10
|
どのようにすれば、エラーなく画面遷移を行えますでしょうか?
|
11
11
|
皆さんのお知恵をお借りできましたら嬉しいです!
|
12
|
+
|
13
|
+
```main.dart
|
14
|
+
import 'package:flutter/material.dart';
|
15
|
+
import 'package:test001/screens/home_screen.dart';
|
16
|
+
import 'package:test001/screens/menu_screen.dart';
|
17
|
+
import 'package:test001/screens/profile_screen.dart';
|
18
|
+
import 'models/routes.dart';
|
19
|
+
|
20
|
+
void main() {
|
21
|
+
runApp(const MyApp());
|
22
|
+
}
|
23
|
+
|
24
|
+
class MyApp extends StatelessWidget {
|
25
|
+
const MyApp({Key? key}) : super(key: key);
|
26
|
+
|
27
|
+
// This widget is the root of your application.
|
28
|
+
@override
|
29
|
+
Widget build(BuildContext context) {
|
30
|
+
return MaterialApp(
|
31
|
+
debugShowCheckedModeBanner: false,
|
32
|
+
title: 'Myapp',
|
33
|
+
theme: ThemeData(
|
34
|
+
primarySwatch: Colors.yellow,
|
35
|
+
textTheme: const TextTheme(
|
36
|
+
titleLarge: TextStyle(
|
37
|
+
fontSize: 20,
|
38
|
+
color: Colors. white,
|
39
|
+
fontWeight: FontWeight.w500,
|
40
|
+
)
|
41
|
+
)
|
42
|
+
),
|
43
|
+
home: const HomeScreen(),
|
44
|
+
);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
```
|
48
|
+
|
12
49
|
|
13
50
|
```cupertino_bottom_navigation.dart
|
14
51
|
import 'package:flutter/cupertino.dart';
|
@@ -50,17 +87,24 @@
|
|
50
87
|
);
|
51
88
|
},
|
52
89
|
);
|
53
|
-
case
|
90
|
+
case 2:
|
54
91
|
return CupertinoTabView(builder: (context) {
|
55
92
|
return const CupertinoPageScaffold(
|
56
93
|
child: ProfileScreen(),
|
57
94
|
);
|
58
95
|
});
|
96
|
+
default:
|
97
|
+
return CupertinoTabView(
|
98
|
+
builder: (context) {
|
99
|
+
return const CupertinoPageScaffold(
|
100
|
+
child: HomeScreen(),
|
101
|
+
);
|
102
|
+
},
|
103
|
+
);
|
59
104
|
}
|
60
105
|
});
|
61
106
|
}
|
62
107
|
}
|
63
|
-
|
64
108
|
```
|
65
109
|
|
66
110
|
|
@@ -87,5 +131,40 @@
|
|
87
131
|
bottomNavigationBar: const BottomNavigation());
|
88
132
|
}
|
89
133
|
}
|
134
|
+
```
|
90
135
|
|
136
|
+
```menu_screen.dart
|
137
|
+
import 'package:flutter/material.dart';
|
138
|
+
|
139
|
+
class MenuScreen extends StatefulWidget{
|
140
|
+
const MenuScreen ({ Key? key }) : super(key: key);
|
141
|
+
|
142
|
+
@override
|
143
|
+
_MenuState createState() => _MenuState();
|
144
|
+
}
|
145
|
+
|
146
|
+
class _MenuState extends State<MenuScreen>{
|
147
|
+
@override
|
148
|
+
Widget build(BuildContext context) => Scaffold(
|
149
|
+
appBar:AppBar(title: Text('メニューページ'),),
|
150
|
+
);
|
151
|
+
}
|
91
152
|
```
|
153
|
+
|
154
|
+
```profile_screen.dart
|
155
|
+
import 'package:flutter/material.dart';
|
156
|
+
|
157
|
+
class ProfileScreen extends StatefulWidget{
|
158
|
+
const ProfileScreen({ Key? key }) : super(key: key);
|
159
|
+
|
160
|
+
@override
|
161
|
+
_ProfileState createState() => _ProfileState();
|
162
|
+
}
|
163
|
+
|
164
|
+
class _ProfileState extends State<ProfileScreen>{
|
165
|
+
@override
|
166
|
+
Widget build(BuildContext context) => Scaffold(
|
167
|
+
appBar:AppBar(title: Text('プロフィールページ'),),
|
168
|
+
);
|
169
|
+
}
|
170
|
+
```
|