No Material widget found

后端 未结 5 944
轮回少年
轮回少年 2020-12-24 00:11

I am new to Flutter and I was trying do execute the example here. I just want to use the TextField widget to get some user input. The issue is that I get a \"No Material wid

5条回答
  •  离开以前
    2020-12-24 01:02

    The error means you have to wrap the column inside a Material widget, you could place it as a body to the scaffold or place it as a home to Materialapp. for instance:

     `return MaterialApp(
           home:  new Column(
           mainAxisAlignment: MainAxisAlignment.center,
          children: [
           new TextField(
          controller: _controller,
          decoration: new InputDecoration(
            hintText: 'Type something',
          ),
        ),
          );`
    

    or

    `return Scaffold(
           body:  new Column(
           mainAxisAlignment: MainAxisAlignment.center,
          children: [
           new TextField(
          controller: _controller,
          decoration: new InputDecoration(
            hintText: 'Type something',
          ),
        ),
          );``
    

提交回复
热议问题