質問編集履歴
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -117,4 +117,128 @@
|
|
117
117
|
|
118
118
|
##
|
119
119
|
以上、どなたか教えてくださると助かります。
|
120
|
-
お願いいたします。
|
120
|
+
お願いいたします。
|
121
|
+
|
122
|
+
|
123
|
+
## 追記
|
124
|
+
修正後のコード
|
125
|
+
```ここに言語を入力
|
126
|
+
//入力画面
|
127
|
+
import 'package:flutter/material.dart';
|
128
|
+
|
129
|
+
void main() {
|
130
|
+
runApp(MyApp());
|
131
|
+
}
|
132
|
+
|
133
|
+
class MyApp extends StatelessWidget {
|
134
|
+
String name;
|
135
|
+
|
136
|
+
@override
|
137
|
+
Widget build(BuildContext context) {
|
138
|
+
return MaterialApp(
|
139
|
+
theme: ThemeData(
|
140
|
+
primarySwatch: Colors.blue,
|
141
|
+
visualDensity: VisualDensity.adaptivePlatformDensity,
|
142
|
+
),
|
143
|
+
home: Scaffold(
|
144
|
+
appBar: AppBar(
|
145
|
+
title: Text('入力画面'),
|
146
|
+
),
|
147
|
+
body: Center(
|
148
|
+
child: Column(
|
149
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
150
|
+
children: [
|
151
|
+
TextField(
|
152
|
+
onChanged: (value) {
|
153
|
+
setState((){
|
154
|
+
name = value;
|
155
|
+
});
|
156
|
+
},
|
157
|
+
decoration: InputDecoration(
|
158
|
+
hintText: 'ここに入力した値を次の画面に渡したい'
|
159
|
+
),
|
160
|
+
),
|
161
|
+
TextField(
|
162
|
+
decoration: InputDecoration(
|
163
|
+
hintText: 'ここに入力した値を次の画面に渡したい'
|
164
|
+
),
|
165
|
+
),
|
166
|
+
RaisedButton(
|
167
|
+
child: Text('確認画面へ'),
|
168
|
+
onPressed: (){
|
169
|
+
Navigator.push(
|
170
|
+
context,
|
171
|
+
MaterialPageRoute(builder: (context) => Scaffold(
|
172
|
+
appBar: AppBar(
|
173
|
+
title: Text('確認画面'),
|
174
|
+
),
|
175
|
+
body: Center(
|
176
|
+
child: Column(
|
177
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
178
|
+
children: [
|
179
|
+
Text(name),
|
180
|
+
Text(name),
|
181
|
+
],
|
182
|
+
),
|
183
|
+
),
|
184
|
+
),
|
185
|
+
),
|
186
|
+
);
|
187
|
+
}
|
188
|
+
),
|
189
|
+
],
|
190
|
+
),
|
191
|
+
),
|
192
|
+
)
|
193
|
+
);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
//確認画面
|
198
|
+
class NextPage extends StatelessWidget{
|
199
|
+
|
200
|
+
@override
|
201
|
+
Widget build(BuildContext context) {
|
202
|
+
return MaterialApp(
|
203
|
+
theme: ThemeData(
|
204
|
+
primarySwatch: Colors.blue,
|
205
|
+
visualDensity: VisualDensity.adaptivePlatformDensity,
|
206
|
+
),
|
207
|
+
home: NextPage2(),
|
208
|
+
);
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
class NextPage2 extends StatelessWidget{
|
213
|
+
NextPage2({this.name});
|
214
|
+
final String name;
|
215
|
+
|
216
|
+
@override
|
217
|
+
Widget build(BuildContext context){
|
218
|
+
return Scaffold(
|
219
|
+
appBar: AppBar(
|
220
|
+
title: Text('確認画面'),
|
221
|
+
),
|
222
|
+
body: Center(
|
223
|
+
child: Column(
|
224
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
225
|
+
children: [
|
226
|
+
Text(name),
|
227
|
+
Text(name),
|
228
|
+
],
|
229
|
+
),
|
230
|
+
),
|
231
|
+
);
|
232
|
+
}
|
233
|
+
}
|
234
|
+
```
|
235
|
+
|
236
|
+
エラー
|
237
|
+
```ここに言語を入力
|
238
|
+
lib/main.dart:28:21: Error: The method 'setState' isn't defined for the class 'MyApp'.
|
239
|
+
- 'MyApp' is from 'package:test20210124/main.dart' ('lib/main.dart').
|
240
|
+
Try correcting the name to the name of an existing method, or defining a method named 'setState'.
|
241
|
+
setState((){
|
242
|
+
^^^^^^^^
|
243
|
+
|
244
|
+
```
|
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -78,8 +78,6 @@
|
|
78
78
|
|
79
79
|
//確認画面
|
80
80
|
class NextPage extends StatelessWidget{
|
81
|
-
NextPage({this.name});
|
82
|
-
final String name;
|
83
81
|
|
84
82
|
@override
|
85
83
|
Widget build(BuildContext context) {
|
@@ -88,23 +86,33 @@
|
|
88
86
|
primarySwatch: Colors.blue,
|
89
87
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
90
88
|
),
|
91
|
-
home:
|
89
|
+
home: NextPage2(),
|
92
|
-
appBar: AppBar(
|
93
|
-
title: Text('確認画面'),
|
94
|
-
),
|
95
|
-
body: Center(
|
96
|
-
child: Column(
|
97
|
-
mainAxisAlignment: MainAxisAlignment.center,
|
98
|
-
children: [
|
99
|
-
Text(name),
|
100
|
-
Text(name),
|
101
|
-
],
|
102
|
-
),
|
103
|
-
),
|
104
|
-
)
|
105
90
|
);
|
106
91
|
}
|
107
92
|
}
|
93
|
+
|
94
|
+
class NextPage2 extends StatelessWidget{
|
95
|
+
NextPage2({this.name});
|
96
|
+
final String name;
|
97
|
+
|
98
|
+
@override
|
99
|
+
Widget build(BuildContext context){
|
100
|
+
return Scaffold(
|
101
|
+
appBar: AppBar(
|
102
|
+
title: Text('確認画面'),
|
103
|
+
),
|
104
|
+
body: Center(
|
105
|
+
child: Column(
|
106
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
107
|
+
children: [
|
108
|
+
Text(name),
|
109
|
+
Text(name),
|
110
|
+
],
|
111
|
+
),
|
112
|
+
),
|
113
|
+
);
|
114
|
+
}
|
115
|
+
}
|
108
116
|
```
|
109
117
|
|
110
118
|
##
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,6 +8,15 @@
|
|
8
8
|
Navigator operation requested with a context that does not include a Navigator.
|
9
9
|
```
|
10
10
|
|
11
|
+
実行ボタンを押すと下記エラーが表示される。
|
12
|
+
```ここに言語を入力
|
13
|
+
lib/main.dart:28:21: Error: The method 'setState' isn't defined for the class 'MyApp'.
|
14
|
+
- 'MyApp' is from 'package:test20210123/main.dart' ('lib/main.dart').
|
15
|
+
Try correcting the name to the name of an existing method, or defining a method named 'setState'.
|
16
|
+
setState((){
|
17
|
+
^^^^^^^^
|
18
|
+
```
|
19
|
+
|
11
20
|
## コード
|
12
21
|
```ここに言語を入力
|
13
22
|
//入力画面
|
@@ -18,51 +27,60 @@
|
|
18
27
|
}
|
19
28
|
|
20
29
|
class MyApp extends StatelessWidget {
|
30
|
+
String name;
|
21
31
|
|
22
32
|
@override
|
23
33
|
Widget build(BuildContext context) {
|
24
34
|
return MaterialApp(
|
25
|
-
|
35
|
+
theme: ThemeData(
|
26
|
-
|
36
|
+
primarySwatch: Colors.blue,
|
27
|
-
|
37
|
+
visualDensity: VisualDensity.adaptivePlatformDensity,
|
28
|
-
),
|
29
|
-
home: Scaffold(
|
30
|
-
appBar: AppBar(
|
31
|
-
title: Text('入力画面'),
|
32
38
|
),
|
33
|
-
|
39
|
+
home: Scaffold(
|
34
|
-
|
40
|
+
appBar: AppBar(
|
35
|
-
mainAxisAlignment: MainAxisAlignment.center,
|
36
|
-
children: [
|
37
|
-
TextField(
|
38
|
-
decoration: InputDecoration(
|
39
|
-
|
41
|
+
title: Text('入力画面'),
|
40
|
-
),
|
41
42
|
),
|
43
|
+
body: Center(
|
44
|
+
child: Column(
|
45
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
46
|
+
children: [
|
42
|
-
|
47
|
+
TextField(
|
48
|
+
onChanged: (value) {
|
49
|
+
setState((){
|
50
|
+
name = value;
|
51
|
+
});
|
52
|
+
},
|
43
|
-
|
53
|
+
decoration: InputDecoration(
|
44
|
-
|
54
|
+
hintText: 'ここに入力した値を次の画面に渡したい'
|
45
|
-
|
55
|
+
),
|
56
|
+
),
|
57
|
+
TextField(
|
58
|
+
decoration: InputDecoration(
|
59
|
+
hintText: 'ここに入力した値を次の画面に渡したい'
|
60
|
+
),
|
61
|
+
),
|
62
|
+
RaisedButton(
|
63
|
+
child: Text('確認画面へ'),
|
64
|
+
onPressed: (){
|
65
|
+
Navigator.push(
|
66
|
+
context,
|
67
|
+
MaterialPageRoute(builder: (context) => NextPage(name: name)),
|
68
|
+
);
|
69
|
+
}
|
70
|
+
),
|
71
|
+
],
|
46
72
|
),
|
47
|
-
RaisedButton(
|
48
|
-
child: Text('確認画面へ'),
|
49
|
-
onPressed: (){
|
50
|
-
Navigator.push(
|
51
|
-
context,
|
52
|
-
MaterialPageRoute(builder: (context) => NextPage()),
|
53
|
-
);
|
54
|
-
}
|
55
|
-
),
|
56
|
-
],
|
57
73
|
),
|
58
|
-
),
|
59
|
-
|
74
|
+
)
|
60
75
|
);
|
61
76
|
}
|
62
77
|
}
|
63
78
|
|
64
79
|
//確認画面
|
65
80
|
class NextPage extends StatelessWidget{
|
81
|
+
NextPage({this.name});
|
82
|
+
final String name;
|
83
|
+
|
66
84
|
@override
|
67
85
|
Widget build(BuildContext context) {
|
68
86
|
return MaterialApp(
|
@@ -78,8 +96,8 @@
|
|
78
96
|
child: Column(
|
79
97
|
mainAxisAlignment: MainAxisAlignment.center,
|
80
98
|
children: [
|
81
|
-
Text(
|
99
|
+
Text(name),
|
82
|
-
Text(
|
100
|
+
Text(name),
|
83
101
|
],
|
84
102
|
),
|
85
103
|
),
|