“孩子”在Flutter中不起作用,依赖问题?

时间:2019-09-03 23:23:35

标签: flutter

//My code show error in 'children', i try to change for 'child' but doesn´t work

 class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.black,
        appBar:
        AppBar(backgroundColor: Colors.indigo, title: Text("Bem-Vindo")),
        body: Center(children: <Widget>[
          RaisedButton(
            onPressed: null,
          ),
          RaisedButton(
            onPressed: null,
          ),
        ]));
  }
}

儿童错误 我尝试在屏幕中间放置两个按钮 我尝试更改为“孩子”

1 个答案:

答案 0 :(得分:1)

这与依赖关系无关。
您不能将孩子用于“中心”小部件。
如果要使其水平对齐,请使用;如果要使其垂直对齐,请使用

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.black,
        appBar:
        AppBar(backgroundColor: Colors.indigo, title: Text("Bem-Vindo")),
        body: Center(
          child: Column(
             children: <Widget>[
               RaisedButton(
                 onPressed: null,
               ),
               RaisedButton(
                 onPressed: null,
               ),
            ])
          )
        );
  }
}