How to Solve ʺNo Material widget foundʺ Error in Flutter

In this example, we are going to show you how to solve the "No Material widget found" Error on the Flutter app. This error occurs when you implement the Material widget without any Material ancestor:

See this Also: How to Solve ’No MediaQuery widget found’ Error in Flutter

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building _InkResponseStateWidget(gestures: [tap], mouseCursor:
null, clipped to BoxShape.rectangle, dirty, state: _InkResponseState#f9ca6):
No Material widget found.
_InkResponseStateWidget widgets require a Material widget ancestor.
In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter's
material library, that material is represented by the Material widget. It is the Material widget
that renders ink splashes, for instance. Because of this, many material library widgets require that
there be a Material widget in the tree above them.
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.
The specific widget that could not find a Material ancestor was:
  _InkResponseStateWidget
The ancestors of this widget were:
  ...
  InkWell
  Column
  _SingleChildViewport
  IgnorePointer-[GlobalKey#aad43]
  Semantics
  ...

The widget which are without Material ancestors are listed on the error message, here in our case, the widget without ancestors are:

The ancestors of this widget were:
  ...
  InkWell
  Column
  _SingleChildViewport
  IgnorePointer-[GlobalKey#aad43]
  Semantics
  ...

Method 1: Wrap your widget with MaterialApp() and Scaffold() as parent widget:

MaterialApp(
  home: Scaffold(
    appBar: AppBar(),
    body: YourWidget(),
  ),
)

Method 2: If you don't want to use MaterialApp() and Scaffold() widget:

Material(
  child: YourWidget()
)

Wrap your widget with Material() to escape this error. 

In this way, you can solve the "No Material widget found" error on Flutter App.

No any Comments on this Article


Please Wait...