📜  flutter listtile shape - Dart (1)

📅  最后修改于: 2023-12-03 14:41:15.248000             🧑  作者: Mango

Flutter Listtile Shape

Listtile is a commonly used widget in Flutter for displaying information or options in a compact way. In some cases, we may want to customize the shape of the Listtile, instead of the default rectangular shape. This article will introduce the ways to customize the shape of Listtile in Flutter.

ListTile customization

In Flutter, we can customize the shape of ListTile by using different properties, such as shape, borderRadius, tileColor, etc. Here are some examples:

Custom shape

We can use shape property to create customized shape for ListTile. The shape takes a ShapeBorder object, which defines the shape of the widget. For example, we can create a circular shape for ListTile as below:

ListTile(
  title: Text('Custom shape'),
  shape: CircleBorder(),
)
Custom border radius

We can also use borderRadius property to customize the border radius of the ListTile. The borderRadius takes a BorderRadius object, which defines the border radius of each corner. For example, we can create a rounded shape for ListTile as below:

ListTile(
  title: Text('Custom border radius'),
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(10),
  ),
)

The BorderRadius.circular() takes a radius value, which determines the curvature of the corner.

Custom tile color

We can change the tile color of the ListTile by setting the tileColor property. For example, we can make the tile background color as red as below:

ListTile(
  title: Text('Custom tile color'),
  tileColor: Colors.red,
)
Conclusion

In this article, we introduced the ways to customize the shape of ListTile in Flutter. By using properties like shape, borderRadius, and tileColor, we can create unique and personalized Listtiles for different needs.

Happy coding!