0

I am looking for someway to add ripple effect on the png or svg images in flutter, without covering the transparent parts in image.

I use this code to add ripple effect over an svg image:

Stack(
      children: [
        SvgPicture.asset(
          R_Image.BACK,
          width: 45,
          height: 45,
          fit: BoxFit.fill,
        ),
        Positioned.fill(
          child: Material(
            color: Colors.transparent,
            child: InkWell(
              onTap: () {
                Navigator.of(context).pop();
              },
            ),
          ),
        ),
      ],
    )

And the result is as follows:

back button without cutting transparent parts

How to remove transparent parts of svg image from ripple effect?

In android, I use @android:id/mask for this purpose, but how to do that in flutter?

amir_a14
  • 1,478
  • 10
  • 15

2 Answers2

0

Try to wrap Stack with ClipRRect

ClipRRect(
  borderRadius: BorderRadius.circular(10.0),
  child: Stack(
    clipBehavior: Clip.none,
    children: [
      SvgPicture.asset(
        R_Image.BACK,
        width: 45,
        height: 45,
        fit: BoxFit.fill,
      ),
      Positioned.fill(
        child: Material(
          color: Colors.transparent,
          child: InkWell(
            onTap: () {
              Navigator.of(context).pop();
            },
          ),
        ),
      ),
    ],
  ),
),
Mayvas
  • 569
  • 4
  • 16
  • This method does not depend on transparent pixels of image, So this is not accurate and not work with different images – amir_a14 Oct 09 '21 at 09:44
0

Try this

 body: new Center(
    child: new Container(
      child: new Material(
        child: new InkWell(
          onTap: (){print("tapped");},
          child: new Container(
            width: 100.0,
            height: 100.0,
          ),
        ),
        color: Colors.transparent,
      ),
      color: Colors.orange,
    ),
  ),