Flutter - ListTile Widget
Last Updated :
08 Jun, 2025
The ListTile widget is used to populate a ListView in Flutter. It contains a title as well as leading or trailing icons. Let's understand this with the help of an example.
Constructor of the ListTile class
ListTile ListTile({
Key? key,
Widget? leading,
Widget? title,
Widget? subtitle,
Widget? trailing,
bool isThreeLine = false,
bool? dense,
VisualDensity? visualDensity,
ShapeBorder? shape,
ListTileStyle? style,
Color? selectedColor,
Color? iconColor,
Color? textColor,
TextStyle? titleTextStyle,
TextStyle? subtitleTextStyle,
TextStyle? leadingAndTrailingTextStyle,
EdgeInsetsGeometry? contentPadding,
bool enabled = true,
void Function()? onTap,
void Function()? onLongPress,
void Function(bool)? onFocusChange,
MouseCursor? mouseCursor,
bool selected = false,
Color? focusColor,
Color? hoverColor,
Color? splashColor,
FocusNode? focusNode,
bool autofocus = false,
Color? tileColor,
Color? selectedTileColor,
bool? enableFeedback,
double? horizontalTitleGap,
double? minVerticalPadding,
double? minLeadingWidth,
double? minTileHeight,
ListTileTitleAlignment? titleAlignment,
bool internalAddSemanticForOnTap = true,
})
Properties
Property
| Description |
---|
autofocus | This property takes in a boolean as the object to decide whether this widget will be selected on the initial focus or not. |
---|
contentPadding | By taking EdgeInsetsGeometry as the object, this property controls the padding. |
---|
dense | This property decides whether the ListTile will be a part of a vertically dense list or not by taking in a boolean as the object. |
---|
enable | This property controls whether the ListTile will be interactive or not by taking in a boolean as the object. |
---|
focusColor | This property holds the Color class as the object to control the color of the widget at the time of input focus. |
---|
focusNode | This property provides an additional node. |
---|
hoverColor | This property takes in the Color class as the object to decide the color of the tile at the time of hover. |
---|
isThreeLine | Whether this list item should display three lines of text or not. |
---|
leading | Leading widget of the ListTile. |
---|
mouseCursor | The mouseCursor property holds the MouseCursor class as the object to decide the cursor for the mouse pointer at the time of the pointer event. |
---|
onLongPress | This holds the GestureLongPressCallback typedef as the object |
---|
onTap | Function to be called when the list tile is pressed. |
---|
selected | This property holds a boolean as the object. If set to true, then the text and icon will be painted with the same color. |
---|
selectedTileColor | This property controls the background color of the ListTile when it is selected. |
---|
shape | The shape of the title's InkWell. |
---|
subtitle | additional content displayed below the title. |
---|
titleColor | This property defines the background color of the ListTile when it is not selected, by taking in the Color class as the object. |
---|
tile | title to be given to the ListTile widget. |
---|
trailing | Trailing widget of the ListTile. |
---|
visualDensity | This property takes in the VisualDensity class as the object. It defines the compactness in the layout of the ListTile. |
---|
main.dart:
main.dart
// ignore_for_file: deprecated_member_use
// This comment tells the Dart analyzer to ignore warnings about deprecated members being used.
// Importing Flutter's Material package which contains UI components.
import 'package:flutter/material.dart';
// The main function is the entry point of the Flutter application.
void main() {
runApp(const MyApp()); // Running the root widget of the app.
}
// Defining a stateless widget named MyApp.
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key); // Constructor with optional key.
// The build method describes the part of the UI represented by this widget.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'ListTile', // Title of the app.
theme: ThemeData(primarySwatch: Colors.blue), // Setting the app theme with a blue color.
home: const MyHomePage(), // Setting MyHomePage as the home screen.
debugShowCheckedModeBanner: false, // Hides the debug banner.
);
}
}
// Defining a stateful widget named MyHomePage.
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key); // Constructor with optional key.
@override
// Creates the mutable state for this widget.
_MyHomePageState createState() => _MyHomePageState();
}
// The state class associated with MyHomePage.
class _MyHomePageState extends State<MyHomePage> {
String txt = ''; // Variable to hold the text shown after tapping ListTile.
@override
Widget build(BuildContext context) {
return Scaffold(
// AppBar displays a toolbar at the top of the screen.
appBar: AppBar(
title: const Text('GeeksforGeeks'), // AppBar title.
backgroundColor: Colors.green, // Background color of AppBar.
foregroundColor: Colors.white, // Text/icon color on AppBar.
),
backgroundColor: Colors.grey[100], // Background color of the page body.
// The main content of the page, organized in a column.
body: Column(
children: <Widget>[
// Adds padding around the ListTile container.
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
color: Colors.blue[50], // Background color of the container.
child: ListTile(
leading: const Icon(Icons.add), // Icon displayed at the start.
title: const Text('GFG title', textScaleFactor: 1.5), // Main title with increased text size.
trailing: const Icon(Icons.done), // Icon displayed at the end.
subtitle: const Text('This is subtitle'), // Secondary text below the title.
selected: true, // Visually marks the ListTile as selected.
// Function executed when the ListTile is tapped.
onTap: () {
setState(() {
txt = 'List Tile pressed'; // Updates the text when tapped.
});
},
),
),
),
// Displays the updated text when ListTile is pressed.
Text(txt, textScaleFactor: 2), // Doubles the size of the text.
],
),
);
}
}
Output:
If the properties are defined as below:
const ListTile(
leading: Icon(Icons.add),
title: Text(
'GFG title',
textScaleFactor: 1.5,
),
trailing: Icon(Icons.done),
),
The following design changes can be observed:
If the properties are defined as below:
const ListTile(
leading: Icon(Icons.add),
title: Text(
'GFG title',
textScaleFactor: 1.5,
),
trailing: Icon(Icons.done),
subtitle: Text('This is subtitle'),
selected: true,
),
The following design changes can be observed:
If the properties are defined as below:
ListTile (
leading: const Icon(Icons.add),
title: const Text(
'GFG title',
textScaleFactor: 1.5,
),
trailing: const Icon(Icons.done),
subtitle: const Text('This is subtitle'),
selected: true,
onTap: () {
setState(() {
txt = 'List Tile pressed';
});
},
),
// when user tap the list tile then below output will be shown.
The following design changes can be observed:
Output:
- Create a ListTile widget and wrap it with a Container widget.
- After that, give ListTile a title, leading, trailing, onTap, etc.
- Add other widgets also, like subtitle, selected, etc.
Similar Reads
Flutter - RadioListTile Widget RadioListTile is a widget that combines a radio button with a list tile. It is often used in scenarios where you need to present a list of mutually exclusive options, and the user can select one option from the list. Each RadioListTile represents a single option in the list and consists of a title,
5 min read
Flutter - Stateful Widget A Stateful Widget has states in it. To understand a Stateful Widget, you need to have a clear understanding of widgets and state management. A state can be defined as "an imperative changing of the user interface," and a widget is "an immutable description of the part of the user interface". To lear
4 min read
Table Widget in Flutter Table widget is used to display items in a table layout. There is no need to use Rows and Columns to create a table. If we have multiple rows with the same width of columns then Table widget is the right approach. SliverList or Column will be most suitable if we only want to have a single column. Th
3 min read
Flutter - Stepper Widget In this article, we will learn about the Stepper widget in Flutter. A stepper widget displays progress through a sequence of steps. A stepper is generally used in filling out forms online.For example, remember filling out an online form for applying to any university or passport, or driving license.
6 min read
Flutter - Stack Widget The Stack widget in Flutter is a powerful tool that allows for the layering of multiple widgets on top of each other. While layouts like Row and Column arrange widgets horizontally and vertically, respectively, Stack provides a solution when you need to overlay widgets. For instance, if you want to
6 min read