Search code examples
flutterlistviewbordershapes

how to use shape in ListTileTheme?


ListTileTheme(

          shape: ??? ,

          tileColor: MyTheme.redColor,
          contentPadding: EdgeInsets.only(right: 0),
          child: ExpansionTile()
        )

I Need to make a border-radius , how can I do this ?


Solution

  • There are a couple of ways to do this. You can use a widget such as ClipRRect to create a border radius.

    Example:

        return ClipRRect(
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(32),
            bottomLeft: Radius.circular(32),
          ),
          child: ListTile(),
        );
    

    If you want to use the shape parameter in ListTileTheme, you can use RoundedRectangleBorder like this:

    return ListTileTheme(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(16),
      ),
      child: ListTile(),
    ),