I have created this custom widget and wrapped with inkwell but its not showing inkwell effect else working fine..
and i am facing this issue so many times mainly when i wrapped inkwell to container.
Whats wrong with my c
class BoxTile extends StatelessWidget {
final String title;
final VoidCallback? onTap;
const BoxTile({Key? key, required this.title, this.onTap}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.grey, width: 2),
borderRadius: BorderRadius.circular(20),
),
child: Center(
child: Text(
title,
style: TextStyle(
fontSize: 40,
color:title=='X'? Colors.green:Colors.blue,
fontWeight: FontWeight.bold
)
),
),
),
);
}
}
2
Answers
You can try wrapping your
InkWell
with aMaterial
.InkWell
uses the nextMaterial
widget to show the effect, which is why it does not work if there is none.You just need to add a few things:
InkWell
widget with aMaterial
.Material
.Container
.borderRadius
forMaterial
andInkWell
.Result:
Code: