この記事の目次
複数のWidgetをリスト化してスクロールで表示できる。
childrenプロパティで表示するWidgetを指定します。
titleプロパティは、表示されれるタイトルを指定します。
title: Text("Menu01"),
leadingプロパティは、ListTileの1番左(titleの前)に表示されるアイコンを指定します。
leading: Icon(Icons.chevron_right_outlined),
trailingプロパティは、ListTileの1番右(titleの後)に表示されるアイコンを指定します。
trailing: Icon(Icons.chevron_right_outlined),
subtitleプロパティは、titleの下に表示されるサブタイトルを指定します。
subtitle: Text("Hello World"),
denseプロパティは、垂直方向に対して密度を高めます。
dense: true,
onTapプロパティは、クリックされた時、定義したコールバック関数を実行します。
onLongPressプロパティは、長押しされた時、定義したコールバック関数を実行します。
child: ListView(
children: const [
ListTile(
title: Text("Menu01"), // タイトルを指定
leading: Icon(Icons.chevron_right_outlined), // 左に表示されるアイコンを指定
trailing: Icon(Icons.chevron_right_outlined), // 右に表示されるアイコンを指定
subtitle: Text("Menu01のsubtitle"), // サブタイトルを指定
dense: true, // 垂直方向に対して密度を高る
onTap: () {print("クリックされました!");}, // クリックされた時
onLongPress: () {print("長押しされました!");}, // 長押しされた時
),
ListTile(
title: Text("Menu02"),
trailing: Icon(Icons.chevron_right_outlined),
),
],
),