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
686d78d4
Unverified
Commit
686d78d4
authored
May 13, 2021
by
Hans Muller
Committed by
GitHub
May 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected OverflowBar layout when it is wider that its intrinsic width (#82380)
parent
58ab556f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
7 deletions
+52
-7
overflow_bar.dart
packages/flutter/lib/src/widgets/overflow_bar.dart
+15
-7
overflow_bar_test.dart
packages/flutter/test/widgets/overflow_bar_test.dart
+37
-0
No files found.
packages/flutter/lib/src/widgets/overflow_bar.dart
View file @
686d78d4
...
@@ -510,17 +510,25 @@ class _RenderOverflowBar extends RenderBox
...
@@ -510,17 +510,25 @@ class _RenderOverflowBar extends RenderBox
}
}
size
=
constraints
.
constrain
(
Size
(
constraints
.
maxWidth
,
y
-
overflowSpacing
));
size
=
constraints
.
constrain
(
Size
(
constraints
.
maxWidth
,
y
-
overflowSpacing
));
}
else
{
}
else
{
// Default horizontal layout
// Default horizontal layout
.
child
=
rtl
?
lastChild
:
firstChild
;
size
=
constraints
.
constrain
(
Size
(
actualWidth
,
maxChildHeight
))
;
RenderBox
?
nextChild
()
=>
rtl
?
childBefore
(
child
!)
:
childAfter
(
child
!)
;
child
=
firstChild
;
double
x
=
0
;
double
x
=
rtl
?
size
.
width
-
child
!.
size
.
width
:
0
;
while
(
child
!=
null
)
{
while
(
child
!=
null
)
{
final
_OverflowBarParentData
childParentData
=
child
.
parentData
!
as
_OverflowBarParentData
;
final
_OverflowBarParentData
childParentData
=
child
.
parentData
!
as
_OverflowBarParentData
;
childParentData
.
offset
=
Offset
(
x
,
(
maxChildHeight
-
child
.
size
.
height
)
/
2
);
childParentData
.
offset
=
Offset
(
x
,
(
maxChildHeight
-
child
.
size
.
height
)
/
2
);
// x is the horizontal origin of child. To advance x to the next child's
// origin for LTR: add the width of the current child. To advance x to
// the origin of the next child for RTL: subtract the width of the next
// child (if there is one).
if
(!
rtl
)
{
x
+=
child
.
size
.
width
+
spacing
;
x
+=
child
.
size
.
width
+
spacing
;
child
=
nextChild
();
}
}
size
=
constraints
.
constrain
(
Size
(
actualWidth
,
maxChildHeight
));
child
=
childAfter
(
child
);
if
(
rtl
&&
child
!=
null
)
{
x
-=
child
.
size
.
width
+
spacing
;
}
}
}
}
}
}
...
...
packages/flutter/test/widgets/overflow_bar_test.dart
View file @
686d78d4
...
@@ -234,4 +234,41 @@ void main() {
...
@@ -234,4 +234,41 @@ void main() {
await
tester
.
pumpWidget
(
buildFrame
(
maxWidth:
150
));
await
tester
.
pumpWidget
(
buildFrame
(
maxWidth:
150
));
expect
(
tester
.
getSize
(
find
.
byType
(
OverflowBar
)).
height
,
166
);
// 166 = 50 + 8 + 25 + 8 + 75
expect
(
tester
.
getSize
(
find
.
byType
(
OverflowBar
)).
height
,
166
);
// 166 = 50 + 8 + 25 + 8 + 75
});
});
testWidgets
(
'OverflowBar is wider that its intrinsic width'
,
(
WidgetTester
tester
)
async
{
final
Key
key0
=
UniqueKey
();
final
Key
key1
=
UniqueKey
();
final
Key
key2
=
UniqueKey
();
Widget
buildFrame
(
TextDirection
textDirection
)
{
return
Directionality
(
textDirection:
textDirection
,
child:
SizedBox
(
width:
800
,
// intrinsic width = 50 + 10 + 60 + 10 + 70 = 200
child:
OverflowBar
(
spacing:
10
,
children:
<
Widget
>[
SizedBox
(
key:
key0
,
width:
50
,
height:
50
),
SizedBox
(
key:
key1
,
width:
60
,
height:
50
),
SizedBox
(
key:
key2
,
width:
70
,
height:
50
),
],
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
TextDirection
.
ltr
));
expect
(
tester
.
getSize
(
find
.
byType
(
OverflowBar
)),
const
Size
(
800.0
,
600.0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
key0
)).
dx
,
0
);
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
key1
)).
dx
,
60
);
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
key2
)).
dx
,
130
);
await
tester
.
pumpWidget
(
buildFrame
(
TextDirection
.
rtl
));
expect
(
tester
.
getSize
(
find
.
byType
(
OverflowBar
)),
const
Size
(
800.0
,
600.0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
key0
)).
dx
,
750
);
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
key1
)).
dx
,
680
);
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
key2
)).
dx
,
600
);
});
}
}
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