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
fb633715
Unverified
Commit
fb633715
authored
Nov 10, 2020
by
Darren Austin
Committed by
GitHub
Nov 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for the ListTile horizontalTitleGap calculation introduced with PR #64222. (#70149)
parent
dbcd7868
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
5 deletions
+54
-5
list_tile.dart
packages/flutter/lib/src/material/list_tile.dart
+6
-5
list_tile_test.dart
packages/flutter/test/material/list_tile_test.dart
+48
-0
No files found.
packages/flutter/lib/src/material/list_tile.dart
View file @
fb633715
...
...
@@ -1404,7 +1404,7 @@ class _RenderListTile extends RenderBox {
_textDirection
=
textDirection
,
_titleBaselineType
=
titleBaselineType
,
_subtitleBaselineType
=
subtitleBaselineType
,
_horizontalTitleGap
=
horizontalTitleGap
+
visualDensity
.
horizontal
*
2.0
,
_horizontalTitleGap
=
horizontalTitleGap
,
_minVerticalPadding
=
minVerticalPadding
,
_minLeadingWidth
=
minLeadingWidth
;
...
...
@@ -1519,6 +1519,7 @@ class _RenderListTile extends RenderBox {
double
get
horizontalTitleGap
=>
_horizontalTitleGap
;
double
_horizontalTitleGap
;
double
get
_effectiveHorizontalTitleGap
=>
_horizontalTitleGap
+
visualDensity
.
horizontal
*
2.0
;
set
horizontalTitleGap
(
double
value
)
{
assert
(
value
!=
null
);
...
...
@@ -1602,7 +1603,7 @@ class _RenderListTile extends RenderBox {
@override
double
computeMinIntrinsicWidth
(
double
height
)
{
final
double
leadingWidth
=
leading
!=
null
?
math
.
max
(
leading
!.
getMinIntrinsicWidth
(
height
),
_minLeadingWidth
)
+
_
h
orizontalTitleGap
?
math
.
max
(
leading
!.
getMinIntrinsicWidth
(
height
),
_minLeadingWidth
)
+
_
effectiveH
orizontalTitleGap
:
0.0
;
return
leadingWidth
+
math
.
max
(
_minWidth
(
title
,
height
),
_minWidth
(
subtitle
,
height
))
...
...
@@ -1612,7 +1613,7 @@ class _RenderListTile extends RenderBox {
@override
double
computeMaxIntrinsicWidth
(
double
height
)
{
final
double
leadingWidth
=
leading
!=
null
?
math
.
max
(
leading
!.
getMaxIntrinsicWidth
(
height
),
_minLeadingWidth
)
+
_
h
orizontalTitleGap
?
math
.
max
(
leading
!.
getMaxIntrinsicWidth
(
height
),
_minLeadingWidth
)
+
_
effectiveH
orizontalTitleGap
:
0.0
;
return
leadingWidth
+
math
.
max
(
_maxWidth
(
title
,
height
),
_maxWidth
(
subtitle
,
height
))
...
...
@@ -1708,10 +1709,10 @@ class _RenderListTile extends RenderBox {
);
final
double
titleStart
=
hasLeading
?
math
.
max
(
_minLeadingWidth
,
leadingSize
.
width
)
+
_
h
orizontalTitleGap
?
math
.
max
(
_minLeadingWidth
,
leadingSize
.
width
)
+
_
effectiveH
orizontalTitleGap
:
0.0
;
final
double
adjustedTrailingWidth
=
hasTrailing
?
math
.
max
(
trailingSize
.
width
+
_
h
orizontalTitleGap
,
32.0
)
?
math
.
max
(
trailingSize
.
width
+
_
effectiveH
orizontalTitleGap
,
32.0
)
:
0.0
;
final
BoxConstraints
textConstraints
=
looseConstraints
.
tighten
(
width:
tileWidth
-
titleStart
-
adjustedTrailingWidth
,
...
...
packages/flutter/test/material/list_tile_test.dart
View file @
fb633715
...
...
@@ -1929,6 +1929,54 @@ void main() {
expect
(
right
(
'title'
),
728.0
);
});
testWidgets
(
'ListTile horizontalTitleGap with visualDensity'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
double
?
horizontalTitleGap
,
VisualDensity
?
visualDensity
})
{
return
MediaQuery
(
data:
const
MediaQueryData
(
padding:
EdgeInsets
.
zero
,
textScaleFactor:
1.0
,
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Material
(
child:
Container
(
alignment:
Alignment
.
topLeft
,
child:
ListTile
(
visualDensity:
visualDensity
,
horizontalTitleGap:
horizontalTitleGap
,
leading:
const
Text
(
'L'
),
title:
const
Text
(
'title'
),
trailing:
const
Text
(
'T'
),
),
),
),
),
);
}
double
left
(
String
text
)
=>
tester
.
getTopLeft
(
find
.
text
(
text
)).
dx
;
await
tester
.
pumpWidget
(
buildFrame
(
horizontalTitleGap:
10.0
,
visualDensity:
const
VisualDensity
(
horizontal:
VisualDensity
.
minimumDensity
),
));
expect
(
tester
.
getSize
(
find
.
byType
(
ListTile
)),
const
Size
(
800.0
,
56.0
));
expect
(
left
(
'title'
),
58.0
);
// Pump another frame of the same widget to ensure the underlying render
// object did not cache the original horizontalTitleGap calculation based on the
// visualDensity
await
tester
.
pumpWidget
(
buildFrame
(
horizontalTitleGap:
10.0
,
visualDensity:
const
VisualDensity
(
horizontal:
VisualDensity
.
minimumDensity
),
));
expect
(
tester
.
getSize
(
find
.
byType
(
ListTile
)),
const
Size
(
800.0
,
56.0
));
expect
(
left
(
'title'
),
58.0
);
});
testWidgets
(
'ListTile minVerticalPadding = 80.0'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
(
TextDirection
textDirection
,
{
double
?
themeMinVerticalPadding
,
double
?
widgetMinVerticalPadding
})
{
return
MediaQuery
(
...
...
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