0%

错误 No Material widget found.

错误最后两行提示

1
2
I/flutter (30116): Another exception was thrown: No Material widget found.
I/flutter (30116): Another exception was thrown: A RenderFlex overflowed by 199318 pixels on the bottom.

如下

error

代码:

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
@override
Widget build(BuildContext context) {
// TODO: implement build
return StoreConnector<InfoState, User>(
converter: (store) {
_store = store;
return store.state.user;
},
builder: (context, user) {
return _getBody();
},
);
}

Widget _getBody() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(horizontal: 50),
width: double.infinity,
child: TextField(
controller: passwd2Controller,
decoration: InputDecoration(
hintText: "new password",
labelText: "输入新密码",
),
),
),
],
);
}

builder 不能直接传入 Column ,否则报错

必须在上面再加一层 Scaffold

如下即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Widget _getBody() {
return Scaffold( // 增加 Scaffold
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(horizontal: 50),
width: double.infinity,
child: TextField(
controller: passwd2Controller,
decoration: InputDecoration(
hintText: "new password",
labelText: "输入新密码",
),
),
),
],
),
);
}