No Material widget found

The error message says:

To introduce a Material widget, you can either directly include one, or use a widget that contains Material itself, such as a Card, Dialog, Drawer, or Scaffold.

In your case, I'd probably wrap your Column in a Scaffold. This will make it easy to add other material widgets to your app later, such as an AppBar, Drawer, or FloatingActionButton.

@override
Widget build(BuildContext context) {
  return new Scaffold(
    body: new Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        new TextField(
            controller: _controller,
            decoration: new InputDecoration(
                hintText: 'Type something',
            ),
        ),
        new RaisedButton(
            onPressed: () {
              showDialog(
                  context: context,
                  child: new AlertDialog(
                      title: new Text('What you typed'),
                      content: new Text(_controller.text),
                  ),
              );
            },
            child: new Text('DONE'),
        ),
      ],
    ),
  );
}

In my case, I was using a hero widget Inside a scaffold-like this

Scaffold(
  body:Hero(
    child:ListView(
      children:<Widget>[
        TextField(),
           ...
           ...
      ]
    )
  )
);

I simply moved the Hero Widget Outside Scaffold and it solved the problem

Hero(
  child:Scaffold(
    body:ListView(
      children:<Widget>[
        TextField(),
        ...
        ...
      ]
    )
  )
);

Just Wrap your Widegt with Material widget, it fixes the problem.

Material(
  child: InkWell(
    onTap: onPressed,));

Tags:

Flutter