无法将“文本”分配给“FlatButton”

时间:2018-03-02 11:32:26

标签: dart flutter

我在下面写了StatefulWidget,但在这一部分:

new FlatButton(
    child: new Text(
    ...
   )
),

我收到以下错误:

  

[dart]无法将参数类型“Text”分配给参数   输入'Row'。

enter image description here

完整的代码是:

part of awesome_library;

class ContentPage extends StatefulWidget {
  ContentPage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _ContentPageState createState() => new _ContentPageState();
}

class _ContentPageState extends State<ContentPage> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text(
              'Click the button below to navigate back to the home screen ',
              style: Theme.of(context).textTheme.display1,
            ),
            new FlatButton(
              child: new Text(
                "ok",
                style: Theme.of(context).textTheme.display1,
              ),
              textColor: new Color(0xFF66BB6A),               
              onPressed: () => Navigator.of(context).pushNamed('/home'),
        ),
          ],
        ), 
      ),
    );
  }
}

0 个答案:

没有答案