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
16af4aa7
Unverified
Commit
16af4aa7
authored
Feb 10, 2021
by
xubaolin
Committed by
GitHub
Feb 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the NestedScrollView exception when rebuilding during scheduleWarmUpFrame (#75308)
parent
6ad9f784
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
2 deletions
+50
-2
nested_scroll_view.dart
packages/flutter/lib/src/widgets/nested_scroll_view.dart
+7
-2
nested_scroll_view_test.dart
packages/flutter/test/widgets/nested_scroll_view_test.dart
+43
-0
No files found.
packages/flutter/lib/src/widgets/nested_scroll_view.dart
View file @
16af4aa7
...
...
@@ -795,8 +795,13 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont
bool
get
hasScrolledBody
{
for
(
final
_NestedScrollPosition
position
in
_innerPositions
)
{
assert
(
position
.
hasContentDimensions
&&
position
.
hasPixels
);
if
(
position
.
pixels
>
position
.
minScrollExtent
)
{
if
(!
position
.
hasContentDimensions
||
!
position
.
hasPixels
)
{
// It's possible that NestedScrollView built twice before layout phase
// in the same frame. This can happen when the FocusManager schedules a microTask
// that marks NestedScrollView dirty during the warm up frame.
// https://github.com/flutter/flutter/pull/75308
continue
;
}
else
if
(
position
.
pixels
>
position
.
minScrollExtent
)
{
return
true
;
}
}
...
...
packages/flutter/test/widgets/nested_scroll_view_test.dart
View file @
16af4aa7
...
...
@@ -2303,6 +2303,49 @@ void main() {
expect
(
lastUserScrollingDirection
,
ScrollDirection
.
forward
);
});
// Regression test for https://github.com/flutter/flutter/issues/72257
testWidgets
(
'NestedScrollView works well when rebuilding during scheduleWarmUpFrame'
,
(
WidgetTester
tester
)
async
{
bool
?
isScrolled
;
final
Widget
myApp
=
MaterialApp
(
home:
Scaffold
(
body:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Focus
(
onFocusChange:
(
_
)
=>
setState
(
(){}
),
child:
NestedScrollView
(
headerSliverBuilder:
(
BuildContext
context
,
bool
boxIsScrolled
)
{
isScrolled
=
boxIsScrolled
;
return
<
Widget
>[
const
SliverAppBar
(
expandedHeight:
200
,
title:
Text
(
'Test'
),
)
];
},
body:
CustomScrollView
(
slivers:
<
Widget
>[
SliverList
(
delegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
const
Text
(
''
);
},
childCount:
10
,
),
)
],
),
),
);
},
),
),
);
await
tester
.
pumpWidget
(
myApp
,
Duration
.
zero
,
EnginePhase
.
build
);
expect
(
isScrolled
,
false
);
expect
(
tester
.
takeException
(),
isNull
);
});
}
class
TestHeader
extends
SliverPersistentHeaderDelegate
{
...
...
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