I am adding InkWell in Row as Widget but it is throwing me an error:
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building InkWell(gestures: [tap], clipped to BoxShape.rectangle,
flutter: dirty, state: _InkResponseState<InkResponse>#0e6c5):
flutter: No Material widget found.
flutter: InkWell widgets require a Material widget ancestor.
Here is my code:
Container(
color: Colors.red,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
InkWell(
onTap: (){
//Forgot password Tapped
},
child: Text(Constants.forgotPassword),),
],
),
InkWell
Class will always work with a Material Class
Please try the code below.
Code: Wrap the InkWell Class with the Material Class
Material(
child: InkWell(
onTap: (){
//Forgot password Tapped
},
child: Text(Constants.forgotPassword),),
),
Thanks
There are two ways to resolve the above issue.
Replace InkWell
with GestureDetector
GestureDetector(
onTap: () {
},);
Wrap InkWell
with Material
, as InkWell
required Material
Widget to wrap
InkWell(
onTap: () {
},);
Note: 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.
Wrap the InkWell Class with Scaffold, then the issue will be gone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With