I'm trying to use InkWell
to get a ripple effect on top of an image inside of a GridTile
when the user taps on the tile.
I believe the image itself is obscuring the ripple because when I remove the image, I see the ripple.
Below is the code for a single GridTile.
return new InkWell( onTap: () => debugPrint(s.displayName), highlightColor: Colors.pinkAccent, splashColor: Colors.greenAccent, child: new GridTile( footer: new GridTileBar( title: new Text(s.displayName), subtitle: new Text(s.gameName), backgroundColor: Colors.black45, trailing: new Icon( Icons.launch, color: Colors.white, ), ), child: new Image.network( //this is obscuring the InkWell ripple s.imageSrc, fit: BoxFit.cover, ), ), );
I've tried moving the InkWell to different levels of the hierarchy, using DecorationImage
inside a Container
, but none of these seem to work to reveal the ripple.
How can I get the ripple to appear on top of the tile/image?
We wrap the Container widget with an InkWell widget and add the onTap handler. With this code, the splash effect will be created when the text is tapped. But, adding color to the Container will hide this effect, since the Container is opaque.
I was able to get a ripple to appear over the image by using a Stack and wrapping the InkWell in a Material widget.
return new Stack(children: <Widget>[ new Positioned.fill( bottom: 0.0, child: new GridTile( footer: new GridTileBar( title: new Text(s.displayName), subtitle: new Text(s.gameName), backgroundColor: Colors.black45, trailing: new Icon( Icons.launch, color: Colors.white, ), ), child: new Image.network(s.imageSrc, fit: BoxFit.cover)), ), new Positioned.fill( child: new Material( color: Colors.transparent, child: new InkWell( splashColor: Colors.lightGreenAccent, onTap: () => _launchStream(s.displayName), ))), ]);
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