Imran Sk
Imran Sk

Reputation: 327

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 ?

Upvotes: 1

Views: 856

Answers (2)

Shrestha Bibash
Shrestha Bibash

Reputation: 58

Approach 1:

Container(
 decoration: BoxDecoration(
   color: MyTheme.redColor,
   borderRadius: BorderRadius.circular(32),
 ),
 child: ListTile(),
)

Approach 2:

ClipRRect(
   borderRadius: BorderRadius.circular(32),
   child: Container(
     color: MyTheme.redColor,
     child: ListTile(),
   ),
)

Approach 3:

ListTileTheme(
   shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(16),
   ),
   child: ListTile(
     tileColor: MyTheme.redColor, 
   ),
)

Preferred: Approach 2

Upvotes: 0

Benjamin
Benjamin

Reputation: 6171

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(),
),

Upvotes: 2

Related Questions