How to add onClick on image.asset in flutter?

I read other answers and found that you were having issues with border, try this solution.

GestureDetector(
  onTap: () {}, // Image tapped
  child: Image.asset(
    'assets/cat.jpg',
    fit: BoxFit.cover, // Fixes border issues
    width: 110.0,
    height: 110.0,
  ),
)

If you want splash effects, then use Ink.image or Ink with decoration.

InkWell(
  onTap: () {}, // Image tapped
  splashColor: Colors.white10, // Splash color over image
  child: Ink.image(
    fit: BoxFit.cover, // Fixes border issues
    width: 100,
    height: 100,
    image: AssetImage(
      'assets/cat.jpg,
    ),
  ),
)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)