Skip to content

Commit 14136ae

Browse files
authored
Updated custom ListTile examples (flutter#128071)
1 parent 35174cc commit 14136ae

File tree

3 files changed

+33
-56
lines changed

3 files changed

+33
-56
lines changed

examples/api/lib/material/list_tile/custom_list_item.1.dart

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ class CustomListItemApp extends StatelessWidget {
1313

1414
@override
1515
Widget build(BuildContext context) {
16-
return const MaterialApp(
17-
home: CustomListItemExample(),
16+
return MaterialApp(
17+
theme: ThemeData(useMaterial3: true),
18+
home: const CustomListItemExample(),
1819
);
1920
}
2021
}
@@ -39,51 +40,38 @@ class _ArticleDescription extends StatelessWidget {
3940
return Column(
4041
crossAxisAlignment: CrossAxisAlignment.start,
4142
children: <Widget>[
42-
Expanded(
43-
child: Column(
44-
crossAxisAlignment: CrossAxisAlignment.start,
45-
children: <Widget>[
46-
Text(
47-
title,
48-
maxLines: 2,
49-
overflow: TextOverflow.ellipsis,
50-
style: const TextStyle(
51-
fontWeight: FontWeight.bold,
52-
),
53-
),
54-
const Padding(padding: EdgeInsets.only(bottom: 2.0)),
55-
Text(
56-
subtitle,
57-
maxLines: 2,
58-
overflow: TextOverflow.ellipsis,
59-
style: const TextStyle(
60-
fontSize: 12.0,
61-
color: Colors.black54,
62-
),
63-
),
64-
],
43+
Text(
44+
title,
45+
maxLines: 2,
46+
overflow: TextOverflow.ellipsis,
47+
style: const TextStyle(
48+
fontWeight: FontWeight.bold,
6549
),
6650
),
51+
const Padding(padding: EdgeInsets.only(bottom: 2.0)),
6752
Expanded(
68-
child: Column(
69-
crossAxisAlignment: CrossAxisAlignment.start,
70-
mainAxisAlignment: MainAxisAlignment.end,
71-
children: <Widget>[
72-
Text(
73-
author,
74-
style: const TextStyle(
75-
fontSize: 12.0,
76-
color: Colors.black87,
77-
),
78-
),
79-
Text(
80-
'$publishDate - $readDuration',
81-
style: const TextStyle(
82-
fontSize: 12.0,
83-
color: Colors.black54,
84-
),
85-
),
86-
],
53+
child: Text(
54+
subtitle,
55+
maxLines: 2,
56+
overflow: TextOverflow.ellipsis,
57+
style: const TextStyle(
58+
fontSize: 12.0,
59+
color: Colors.black54,
60+
),
61+
),
62+
),
63+
Text(
64+
author,
65+
style: const TextStyle(
66+
fontSize: 12.0,
67+
color: Colors.black87,
68+
),
69+
),
70+
Text(
71+
'$publishDate - $readDuration',
72+
style: const TextStyle(
73+
fontSize: 12.0,
74+
color: Colors.black54,
8775
),
8876
),
8977
],

examples/api/test/material/list_tile/custom_list_item.1_test.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void main() {
2020
expect(thumbnailAspectRatio.aspectRatio, 1.0);
2121

2222
// The Expanded widget is used to control the size of the text.
23-
Expanded textExpanded = tester.widget(find.ancestor(
23+
final Expanded textExpanded = tester.widget(find.ancestor(
2424
of: find.text('Flutter 1.0 Launch'),
2525
matching: find.byType(Expanded).at(0),
2626
));
@@ -32,12 +32,5 @@ void main() {
3232
matching: find.byType(AspectRatio),
3333
));
3434
expect(thumbnailAspectRatio.aspectRatio, 1.0);
35-
36-
// The Expanded widget is used to control the size of the text.
37-
textExpanded = tester.widget(find.ancestor(
38-
of: find.text('Flutter 1.2 Release - Continual updates to the framework'),
39-
matching: find.byType(Expanded).at(3),
40-
));
41-
expect(textExpanded.flex, 1);
4235
});
4336
}

packages/flutter/lib/src/material/list_tile.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,6 @@ enum ListTileTitleAlignment {
296296
/// Here is an example of a custom list item that resembles a YouTube-related
297297
/// video list item created with [Expanded] and [Container] widgets.
298298
///
299-
/// ![Custom list item a](https://flutter.github.io/assets-for-api-docs/assets/widgets/custom_list_item_a.png)
300-
///
301299
/// ** See code in examples/api/lib/material/list_tile/custom_list_item.0.dart **
302300
/// {@end-tool}
303301
///
@@ -306,8 +304,6 @@ enum ListTileTitleAlignment {
306304
/// subtitles. It utilizes [Row]s and [Column]s, as well as [Expanded] and
307305
/// [AspectRatio] widgets to organize its layout.
308306
///
309-
/// ![Custom list item b](https://flutter.github.io/assets-for-api-docs/assets/widgets/custom_list_item_b.png)
310-
///
311307
/// ** See code in examples/api/lib/material/list_tile/custom_list_item.1.dart **
312308
/// {@end-tool}
313309
///

0 commit comments

Comments
 (0)