Create a button with an image in Flutter? Create a button with an image in Flutter? flutter flutter

Create a button with an image in Flutter?


IconButton(  icon: Image.asset('path/the_image.png'),  iconSize: 50,  onPressed: () {},)


I think this should work as well.Just specify the padding for the FlatButton to zero.

Container(child: ConstrainedBox(constraints: BoxConstraints.expand(),child: FlatButton(         onPressed: null,         padding: EdgeInsets.all(0.0),         child: Image.asset('path/the_image.png'))))


My opinion, the easier way and also most versatile is to use GestureDetector as it allows you to call different functions for different gestures like one tap, double-tap, long tap and so on.

GestureDetector(                onTap: () => _yourFunction('yourParameter'),                child: Image.asset('yourimagefolder/yourimage.png'),              ),