Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter ListTile splash/ripple effect not matching border

Tags:

flutter

I have a ListTile in flutter but I cannot seem to figure out how to make the splash/ripple effect fit the border. My border is rounded, but the splash is just a normal rectangle with no round borders, as seen on the image below.

ListTile

Below is the code for the ListTile.

Ink(
    decoration: BoxDecoration(
      borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
    ),
    child: ListTile(
      title: text(title, 0.0),
      leading: Icon(
        icon,
        color: primaryColor,
      ),
    )
)
like image 825
iaminpainpleasehelp Avatar asked Feb 03 '20 14:02

iaminpainpleasehelp


People also ask

How to get ripple effect in flutter?

An easy way to achieve a ripple effect on your flutter app by using the ripple_effect plugin so in today’s article we will walk through How to Solve if InkWell Not Showing Ripple Effect In Flutter. How to Solve if InkWell Not Showing Ripple Effect In Flutter?? Using Inkwell effect code snippet will look like a below: just click the middle square.

How to add splash effect to custom widgets in flutter?

Flutter framework already provides splash effect functionality to many of it’s widgets like RaisedButton, FlatButton, ListTile etc. by default. However, if you want to use this feature to your custom widgets, you will have to explicitly make use of InkWell widget.

Why can’t I see Splash ripple effect on the center and text widgets?

We wrapped the Center and Text widgets by an InkWell widget. But if you run the app now, you would still not be able to see splash ripple effect. This is because an InkWell widget must always have a Material widget as it’s parent widget.

How to change the splash color of a listtile widget?

After seeing a ton of different answers about changing the splash color of different widgets, namely ListTile, here are two quick ways of doing it: Be sure to check your specific widget, as some (such as RaisedButton and IconButton) already have splashColor and highlightColor properties you can set without having to modify or add a Theme.


Video Answer


1 Answers

You can use InkWell:

InkWell(
    customBorder: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(10),
    ),
    onTap: () {},
    splashColor: Colors.red,
    child: ListTile(
        title: Text("Title"),
    ),
),
like image 73
Can Avatar answered Oct 17 '22 16:10

Can