From caf21362f577ac918bd105bd6c7396ecc9939837 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Tue, 13 Jul 2021 09:31:39 -0700 Subject: [PATCH] Additional ListTile API doc - Material widget dependency (#86355) --- .../flutter/lib/src/material/list_tile.dart | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index 730a3f4ffb..eb79192df1 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -269,7 +269,28 @@ enum ListTileControlAffinity { /// List tiles are typically used in [ListView]s, or arranged in [Column]s in /// [Drawer]s and [Card]s. /// -/// Requires one of its ancestors to be a [Material] widget. +/// One ancestor must be a [Material] widget and typically this is +/// provided by the app's [Scaffold]. The [tileColor], +/// [selectedTileColor], [focusColor], and [hoverColor] are not +/// painted by the list tile itself but by the material widget +/// ancestor. This generally has no effect. However, if an opaque +/// widget, like `Container(color: Colors.white)`, is included in +/// between the [ListTile] and its [Material] ancestor, then the +/// opaque widget will obscure the material widget and its background +/// [tileColor], etc. If this a problem, one can wrap a material +/// widget around the list tile, e.g.: +/// +/// ```dart +/// Container( +/// color: Colors.green, +/// child: Material( +/// child: ListTile( +/// title: const Text('ListTile with red background'), +/// tileColor: Colors.red, +/// ), +/// ), +/// ) +/// ``` /// /// {@tool snippet} ///