ListTile class
A single fixed-height row that typically contains some text as well as a leading or trailing icon.
A list tile contains one to three lines of text optionally flanked by icons or other widgets, such as check boxes. The icons (or other widgets) for the tile are defined with the leading and trailing parameters. The first line of text is not optional and is specified with title. The value of subtitle, which is optional, will occupy the space allocated for an additional line of text, or two lines if isThreeLine is true. If dense is true then the overall height of this tile and the size of the DefaultTextStyles that wrap the title and subtitle widget are reduced.
List tiles are always a fixed height (which height depends on how isThreeLine, dense, and subtitle are configured); they do not grow in height based on their contents. If you are looking for a widget that allows for arbitrary layout in a row, consider Row.
List tiles are typically used in ListViews, or arranged in Columns in Drawers and Cards.
Requires one of its ancestors to be a Material widget.
ListTile(
leading: const Icon(Icons.event_seat),
title: const Text('The seat for the narrator'),
)
_act
variable is not 2. When the tile is
tapped, the whole row has an ink splash effect (see InkWell).
int _act = 1;
// ...
ListTile(
leading: const Icon(Icons.flight_land),
title: const Text('Trix\'s airplane'),
subtitle: _act != 2 ? const Text('The airplane is only in Act II.') : null,
enabled: _act == 2,
onTap: () { /* react to the tile being tapped */ }
)
See also:
- ListTileTheme, which defines visual properties for ListTiles.
- ListView, which can display an arbitrary number of ListTiles in a scrolling list.
- CircleAvatar, which shows an icon representing a person and is often used as the leading element of a ListTile.
- Card, which can be used with Column to show a few ListTiles.
- Divider, which can be used to separate ListTiles.
- ListTile.divideTiles, a utility for inserting Dividers in between ListTiles.
- CheckboxListTile, RadioListTile, and SwitchListTile, widgets that combine ListTile with other controls.
- material.google.com/components/lists.html
- Inheritance
Constructors
- ListTile({Key key, Widget leading, Widget title, Widget subtitle, Widget trailing, bool isThreeLine: false, bool dense, EdgeInsetsGeometry contentPadding, bool enabled: true, GestureTapCallback onTap, GestureLongPressCallback onLongPress, bool selected: false })
-
Creates a list tile. [...]
const
Properties
- contentPadding → EdgeInsetsGeometry
-
The tile's internal padding. [...]
final
- dense → bool
-
Whether this list tile is part of a vertically dense list. [...]
final
- enabled → bool
-
Whether this list tile is interactive. [...]
final
- isThreeLine → bool
-
Whether this list tile is intended to display three lines of text. [...]
final
- leading → Widget
-
A widget to display before the title. [...]
final
- onLongPress → GestureLongPressCallback
-
Called when the user long-presses on this list tile. [...]
final
- onTap → GestureTapCallback
-
Called when the user taps this list tile. [...]
final
- selected → bool
-
If this tile is also enabled then icons and text are rendered with the same color. [...]
final
- subtitle → Widget
-
Additional content displayed below the title. [...]
final
- title → Widget
-
The primary content of the list tile. [...]
final
- trailing → Widget
-
A widget to display after the title. [...]
final
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- key → Key
-
Controls how one widget replaces another widget in the tree. [...]
final, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget. [...]
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree. [...]
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children. [...]
@protected, inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node. [...]
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toDiagnosticsNode(
{String name, DiagnosticsTreeStyle style }) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by toStringDeep. [...]
inherited
-
toString(
{DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a string representation of this node and its descendants. [...]
inherited
-
toStringShallow(
{String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a one-line detailed description of the object. [...]
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
divideTiles(
{BuildContext context, Iterable< Widget> tiles, Color color }) → Iterable< Widget> - Add a one pixel border in between each tile. If color isn't specified the ThemeData.dividerColor of the context's Theme is used. [...]