CupertinoListTile constructor

const CupertinoListTile({
  1. Key? key,
  2. required Widget title,
  3. Widget? subtitle,
  4. Widget? additionalInfo,
  5. Widget? leading,
  6. Widget? trailing,
  7. FutureOr<void> onTap()?,
  8. Color? backgroundColor,
  9. Color? backgroundColorActivated,
  10. EdgeInsetsGeometry? padding,
  11. double leadingSize = _kLeadingSize,
  12. double leadingToTitle = _kLeadingToTitle,
})

Creates an edge-to-edge iOS-style list tile like the tiles in iOS Settings app.

The title parameter is required. It is used to convey the most important information of list tile. It is typically a Text.

The subtitle parameter is used to display additional information. It is placed below the title.

The additionalInfo parameter is used to display additional information. It is placed at the end of the tile, before the trailing if supplied.

The leading parameter is typically an Icon or an Image and it comes at the start of the tile. If omitted in all list tiles, a hasLeading of enclosing CupertinoListSection should be set to false to ensure correct margin of divider between tiles.

The trailing parameter is typically a CupertinoListTileChevron, an Icon, or a CupertinoButton. It is placed at the very end of the tile.

The onTap parameter is used to provide an action that is called when the tile is tapped. It is mainly used for navigating to a new route. It should not be used to toggle a trailing CupertinoSwitch and similar use cases because when tile is tapped, it switches the background color and remains changed. This is according to iOS behavior.

The backgroundColor provides a custom background color for the tile in a state before tapped. By default, it matches the theme's background color which is by default a CupertinoColors.systemBackground.

The backgroundColorActivated provides a custom background color for the tile after it was tapped. By default, it matches the theme's background color which is by default a CupertinoColors.systemGrey4.

The padding parameter sets the padding of the content inside the tile. It defaults to a value that matches the iOS look, depending on a type of CupertinoListTile. For native look, it should not be provided.

The leadingSize constrains the width and height of the leading widget. By default, it is set to a value that matches the iOS look, depending on a type of CupertinoListTile. For native look, it should not be provided.

The leadingToTitle specifies the horizontal space between leading and title widgets. By default, it is set to a value that matched the iOS look, depending on a type of CupertinoListTile. For native look, it should not be provided.

Implementation

const CupertinoListTile({
  super.key,
  required this.title,
  this.subtitle,
  this.additionalInfo,
  this.leading,
  this.trailing,
  this.onTap,
  this.backgroundColor,
  this.backgroundColorActivated,
  this.padding,
  this.leadingSize = _kLeadingSize,
  this.leadingToTitle = _kLeadingToTitle,
}) : _type = _CupertinoListTileType.base;