Flutter – ListTile Widget
Last Updated :
28 Aug, 2024
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.
The Constructor of the ListTile class
ListTile({
Key key,
Widget leading,
Widget title,
Widget subtitle,
Widget trailing,
bool isThreeLine: false,
bool dense,
VisualDensity visualDensity,
ShapeBorder shape,
EdgeInsetsGeometry contentPadding,
bool enabled: true,
GestureTapCallback onTap,
GestureLongPressCallback onLongPress,
MouseCursor mouseCursor,
bool selected: false,
Color focusColor,
Color hoverColor,
FocusNode focusNode,
bool autofocus: false
}
)
Properties
| 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 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 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 MouseCursor class as the object to decide the cursor for the mouse pointer at the time of pointer event.
|
---|
onLongPress
| This holds 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 Color class as the object.
|
---|
tile
| title to be given to ListTile widget.
|
---|
trailing
| trailing widget of the ListTile.
|
---|
visualDensity
| This property takes in VisualDensity class as the object. It defines the compactness in the layout of the ListTile.
|
---|
Example of ListTitle Widget
The main.dart file.
main.dart
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
// Class
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is
//the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'ListTile',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
debugShowCheckedModeBanner: false,
);
}
}
// Class
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
// ignore: library_private_types_in_public_api
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String txt = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('GeeksforGeeks'),
backgroundColor: Colors.green,
),
backgroundColor: Colors.grey[100],
body: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
color: Colors.blue[50],
child: 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';
});
},
),
),
),
Text(
txt,
textScaleFactor: 2,
)
],
),
);
}
}
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 explanation:
- Create a ListTile widget and wrap it with 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,
6 min read
Flutter - TabView Widget
There are lots of apps where you often have come across tabs. Tabs are a common pattern in the apps. They are situated at top of the app below the App bar. So today we are going to create our own app with tabs. Table of Contents:Project SetupCodeConclusionProject Setup: You can either create a new p
4 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. Stepper is generally used in filling forms online. For example, remember filling an online form for applying to any university or passport or driving license. We filled
8 min read
OffStage Widget in Flutter
Flutter provides an inbuilt widget called âOffstageâ, which is been used to hide or show any widget programmatically depending on user action/event. Offstage Widget is a widget that lays the child out as if it was in the tree, but without painting anything, without making the child available for hit
4 min read
Flutter - LayoutBuilder Widget
In Flutter, LayoutBuilder Widget is similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints. This is useful when the parent constrains the child's size and doesn't depend on the child's intrinsic size. The LayoutB
3 min read
Flutter - FlutterLogo Widget
FlutterLogo widget is as simple as it sounds, it is just the flutter logo in the form of an icon. This widget also comes built-in with flutter SDK. This widget can found its use as a placeholder for an image or icon. Below we will see its implementation with all its properties and constructor. Const
3 min read
Flutter - SizedBox Widget
SizedBox is a built-in widget in flutter SDK. It is a simple box with a specified size. It can be used to set size constraints to the child widget, put an empty SizedBox between the two widgets to get some space in between, or something else. It is somewhat similar to a Container widget with fewer p
3 min read
Flutter - Inherited Widget
If you are a flutter developer then you know how easy is to create Flutter UI. But when you have lots of widgets in your app and you want to pass data from one widget to another widget, this will be a pain for many developers,s especially for the newbie, this will be really hard for them to pass the
6 min read
Flutter - InkWell Widget
InkWell is the material widget in flutter. It responds to the touch action as performed by the user. Inkwell will respond when the user clicks the button. There are so many gestures like double-tap, long press, tap down, etc. Below are the so many properties of this widget. We can set the radius of
2 min read
RotatedBox Widget in Flutter
The RotatedBox widget is used to rotate its child by an integral number of quarter turns. It is used to orient its child widgets into either horizontal or vertical orientation. Furthermore, it is very lightweight and can be used for designing various UI as it gives flexibility to the user over the D
2 min read