Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
78a0d3d4
Unverified
Commit
78a0d3d4
authored
May 25, 2022
by
Taha Tesser
Committed by
GitHub
May 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[reland] Migrate `ListTile` TextTheme TextStyle references to Material 3 (#102167)
parent
cb9a1d62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
156 additions
and
13 deletions
+156
-13
list_tile.dart
packages/flutter/lib/src/material/list_tile.dart
+9
-5
list_tile_test.dart
packages/flutter/test/material/list_tile_test.dart
+147
-8
No files found.
packages/flutter/lib/src/material/list_tile.dart
View file @
78a0d3d4
...
...
@@ -657,10 +657,10 @@ class ListTile extends StatelessWidget {
final
TextStyle
textStyle
;
switch
(
style
??
tileTheme
.
style
??
theme
.
listTileTheme
.
style
??
ListTileStyle
.
list
)
{
case
ListTileStyle
.
drawer
:
textStyle
=
theme
.
textTheme
.
bodyText1
!;
textStyle
=
theme
.
useMaterial3
?
theme
.
textTheme
.
bodyMedium
!
:
theme
.
textTheme
.
bodyText1
!;
break
;
case
ListTileStyle
.
list
:
textStyle
=
theme
.
textTheme
.
subtitle1
!;
textStyle
=
theme
.
useMaterial3
?
theme
.
textTheme
.
titleMedium
!
:
theme
.
textTheme
.
subtitle1
!;
break
;
}
final
Color
?
color
=
_textColor
(
theme
,
tileTheme
,
textStyle
.
color
);
...
...
@@ -670,15 +670,19 @@ class ListTile extends StatelessWidget {
}
TextStyle
_subtitleTextStyle
(
ThemeData
theme
,
ListTileThemeData
tileTheme
)
{
final
TextStyle
textStyle
=
theme
.
textTheme
.
bodyText2
!;
final
Color
?
color
=
_textColor
(
theme
,
tileTheme
,
theme
.
textTheme
.
caption
!.
color
);
final
TextStyle
textStyle
=
theme
.
useMaterial3
?
theme
.
textTheme
.
bodyMedium
!
:
theme
.
textTheme
.
bodyText2
!;
final
Color
?
color
=
_textColor
(
theme
,
tileTheme
,
theme
.
useMaterial3
?
theme
.
textTheme
.
bodySmall
!.
color
:
theme
.
textTheme
.
caption
!.
color
,
);
return
_isDenseLayout
(
theme
,
tileTheme
)
?
textStyle
.
copyWith
(
color:
color
,
fontSize:
12.0
)
:
textStyle
.
copyWith
(
color:
color
);
}
TextStyle
_trailingAndLeadingTextStyle
(
ThemeData
theme
,
ListTileThemeData
tileTheme
)
{
final
TextStyle
textStyle
=
theme
.
textTheme
.
bodyText2
!;
final
TextStyle
textStyle
=
theme
.
useMaterial3
?
theme
.
textTheme
.
bodyMedium
!
:
theme
.
textTheme
.
bodyText2
!;
final
Color
?
color
=
_textColor
(
theme
,
tileTheme
,
textStyle
.
color
);
return
textStyle
.
copyWith
(
color:
color
);
}
...
...
packages/flutter/test/material/list_tile_test.dart
View file @
78a0d3d4
...
...
@@ -2104,6 +2104,7 @@ void main() {
ListTileStyle
?
style
,
})
{
return
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
true
),
home:
Material
(
child:
Center
(
child:
Builder
(
...
...
@@ -2181,6 +2182,7 @@ void main() {
ListTileStyle
?
style
,
})
{
return
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
true
),
home:
Material
(
child:
Center
(
child:
Builder
(
...
...
@@ -2207,25 +2209,25 @@ void main() {
// ListTile - ListTileStyle.list (default).
await
tester
.
pumpWidget
(
buildFrame
());
RenderParagraph
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Text2
!.
color
);
expect
(
leading
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Medium
!.
color
);
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
color
,
theme
.
textTheme
.
subtitle1
!.
color
);
expect
(
title
.
text
.
style
!.
color
,
theme
.
textTheme
.
titleMedium
!.
color
);
RenderParagraph
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
color
,
theme
.
textTheme
.
caption
!.
color
);
expect
(
subtitle
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodySmall
!.
color
);
RenderParagraph
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Text2
!.
color
);
expect
(
trailing
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Medium
!.
color
);
// ListTile - ListTileStyle.drawer.
await
tester
.
pumpWidget
(
buildFrame
(
style:
ListTileStyle
.
drawer
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Text2
!.
color
);
expect
(
leading
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Medium
!.
color
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Text1
!.
color
);
expect
(
title
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Large
!.
color
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
color
,
theme
.
textTheme
.
caption
!.
color
);
expect
(
subtitle
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodySmall
!.
color
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Text2
!.
color
);
expect
(
trailing
.
text
.
style
!.
color
,
theme
.
textTheme
.
body
Medium
!.
color
);
});
testWidgets
(
'Default ListTile debugFillProperties'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -2299,6 +2301,143 @@ void main() {
expect
(
description
[
22
],
'minVerticalPadding: 2.0'
);
expect
(
description
[
23
],
'minLeadingWidth: 6.0'
);
});
group
(
'Material 2'
,
()
{
// Tests that are only relevant for Material 2. Once ThemeData.useMaterial3
// is turned on by default, these tests can be removed.
testWidgets
(
'ListTile font size'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
bool
dense
=
false
,
bool
enabled
=
true
,
bool
selected
=
false
,
ListTileStyle
?
style
,
})
{
return
MaterialApp
(
home:
Material
(
child:
Center
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
ListTile
(
dense:
dense
,
enabled:
enabled
,
selected:
selected
,
style:
style
,
leading:
const
TestText
(
'leading'
),
title:
const
TestText
(
'title'
),
subtitle:
const
TestText
(
'subtitle'
)
,
trailing:
const
TestText
(
'trailing'
),
);
},
),
),
),
);
}
// ListTile - ListTileStyle.list (default).
await
tester
.
pumpWidget
(
buildFrame
());
RenderParagraph
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
fontSize
,
14.0
);
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
fontSize
,
16.0
);
RenderParagraph
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
fontSize
,
14.0
);
RenderParagraph
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
fontSize
,
14.0
);
// ListTile - Densed - ListTileStyle.list (default).
await
tester
.
pumpWidget
(
buildFrame
(
dense:
true
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
fontSize
,
14.0
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
fontSize
,
13.0
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
fontSize
,
12.0
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
fontSize
,
14.0
);
// ListTile - ListTileStyle.drawer.
await
tester
.
pumpWidget
(
buildFrame
(
style:
ListTileStyle
.
drawer
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
fontSize
,
14.0
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
fontSize
,
14.0
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
fontSize
,
14.0
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
fontSize
,
14.0
);
// ListTile - Densed - ListTileStyle.drawer.
await
tester
.
pumpWidget
(
buildFrame
(
dense:
true
,
style:
ListTileStyle
.
drawer
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
fontSize
,
14.0
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
fontSize
,
13.0
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
fontSize
,
12.0
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
fontSize
,
14.0
);
});
testWidgets
(
'ListTile text color'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
bool
dense
=
false
,
bool
enabled
=
true
,
bool
selected
=
false
,
ListTileStyle
?
style
,
})
{
return
MaterialApp
(
home:
Material
(
child:
Center
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
ListTile
(
dense:
dense
,
enabled:
enabled
,
selected:
selected
,
style:
style
,
leading:
const
TestText
(
'leading'
),
title:
const
TestText
(
'title'
),
subtitle:
const
TestText
(
'subtitle'
)
,
trailing:
const
TestText
(
'trailing'
),
);
},
),
),
),
);
}
final
ThemeData
theme
=
ThemeData
();
// ListTile - ListTileStyle.list (default).
await
tester
.
pumpWidget
(
buildFrame
());
RenderParagraph
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText2
!.
color
);
RenderParagraph
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
color
,
theme
.
textTheme
.
subtitle1
!.
color
);
RenderParagraph
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
color
,
theme
.
textTheme
.
caption
!.
color
);
RenderParagraph
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText2
!.
color
);
// ListTile - ListTileStyle.drawer.
await
tester
.
pumpWidget
(
buildFrame
(
style:
ListTileStyle
.
drawer
));
await
tester
.
pumpAndSettle
();
leading
=
_getTextRenderObject
(
tester
,
'leading'
);
expect
(
leading
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText2
!.
color
);
title
=
_getTextRenderObject
(
tester
,
'title'
);
expect
(
title
.
text
.
style
!.
color
,
theme
.
textTheme
.
subtitle1
!.
color
);
subtitle
=
_getTextRenderObject
(
tester
,
'subtitle'
);
expect
(
subtitle
.
text
.
style
!.
color
,
theme
.
textTheme
.
caption
!.
color
);
trailing
=
_getTextRenderObject
(
tester
,
'trailing'
);
expect
(
trailing
.
text
.
style
!.
color
,
theme
.
textTheme
.
bodyText2
!.
color
);
});
});
}
RenderParagraph
_getTextRenderObject
(
WidgetTester
tester
,
String
text
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment