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
c9312c78
Unverified
Commit
c9312c78
authored
Mar 21, 2022
by
Kate Lovett
Committed by
GitHub
Mar 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix stretch edge case (#99365)
parent
9c521b90
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
2 deletions
+101
-2
sliver_persistent_header.dart
...s/flutter/lib/src/rendering/sliver_persistent_header.dart
+2
-2
slivers_appbar_stretch_test.dart
...ges/flutter/test/widgets/slivers_appbar_stretch_test.dart
+99
-0
No files found.
packages/flutter/lib/src/rendering/sliver_persistent_header.dart
View file @
c9312c78
...
...
@@ -359,7 +359,7 @@ abstract class RenderSliverScrollingPersistentHeader extends RenderSliverPersist
@protected
double
updateGeometry
()
{
double
stretchOffset
=
0.0
;
if
(
stretchConfiguration
!=
null
&&
_childPosition
==
0.0
)
{
if
(
stretchConfiguration
!=
null
)
{
stretchOffset
+=
constraints
.
overlap
.
abs
();
}
final
double
maxExtent
=
this
.
maxExtent
;
...
...
@@ -596,7 +596,7 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste
@protected
double
updateGeometry
()
{
double
stretchOffset
=
0.0
;
if
(
stretchConfiguration
!=
null
&&
_childPosition
==
0.0
)
{
if
(
stretchConfiguration
!=
null
)
{
stretchOffset
+=
constraints
.
overlap
.
abs
();
}
final
double
maxExtent
=
this
.
maxExtent
;
...
...
packages/flutter/test/widgets/slivers_appbar_stretch_test.dart
View file @
c9312c78
...
...
@@ -43,6 +43,105 @@ void main() {
expect
(
header
.
child
!.
size
.
height
,
equals
(
200.0
));
});
testWidgets
(
'fills overscroll after reverse direction input - scrolling header'
,
(
WidgetTester
tester
)
async
{
const
Key
anchor
=
Key
(
'drag'
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
CustomScrollView
(
physics:
const
BouncingScrollPhysics
(),
slivers:
<
Widget
>[
const
SliverAppBar
(
title:
Text
(
'Test'
),
stretch:
true
,
expandedHeight:
100.0
,
),
SliverToBoxAdapter
(
child:
Container
(
key:
anchor
,
height:
800
,
),
),
SliverToBoxAdapter
(
child:
Container
(
height:
800
,
),
),
],
),
),
);
final
RenderSliverScrollingPersistentHeader
header
=
tester
.
renderObject
(
find
.
byType
(
SliverAppBar
),
);
expect
(
header
.
child
!.
size
.
height
,
equals
(
100.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Test'
)).
dy
,
28.0
);
// First scroll the header away
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byKey
(
anchor
)));
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
100.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
header
.
child
!.
size
.
height
,
equals
(
56.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Test'
,
skipOffstage:
false
)).
dy
,
-
28.0
);
// With the same gesture, scroll back and into overscroll
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
200.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
// Header should stretch in overscroll
expect
(
header
.
child
!.
size
.
height
,
equals
(
200.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Test'
)).
dy
,
28.0
);
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
});
testWidgets
(
'fills overscroll after reverse direction input - floating header'
,
(
WidgetTester
tester
)
async
{
const
Key
anchor
=
Key
(
'drag'
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
CustomScrollView
(
physics:
const
BouncingScrollPhysics
(),
slivers:
<
Widget
>[
const
SliverAppBar
(
title:
Text
(
'Test'
),
stretch:
true
,
floating:
true
,
expandedHeight:
100.0
,
),
SliverToBoxAdapter
(
child:
Container
(
key:
anchor
,
height:
800
,
),
),
SliverToBoxAdapter
(
child:
Container
(
height:
800
,
),
),
],
),
),
);
final
RenderSliverFloatingPersistentHeader
header
=
tester
.
renderObject
(
find
.
byType
(
SliverAppBar
),
);
expect
(
header
.
child
!.
size
.
height
,
equals
(
100.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Test'
)).
dy
,
28.0
);
// First scroll the header away
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byKey
(
anchor
)));
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
100.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
header
.
child
!.
size
.
height
,
equals
(
56.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Test'
,
skipOffstage:
false
)).
dy
,
-
28.0
);
// With the same gesture, scroll back and into overscroll
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
200.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
// Header should stretch in overscroll
expect
(
header
.
child
!.
size
.
height
,
equals
(
200.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Test'
)).
dy
,
28.0
);
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
});
testWidgets
(
'does not stretch without overscroll physics'
,
(
WidgetTester
tester
)
async
{
const
Key
anchor
=
Key
(
'drag'
);
await
tester
.
pumpWidget
(
...
...
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