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
cff3211f
Unverified
Commit
cff3211f
authored
Apr 26, 2021
by
xubaolin
Committed by
GitHub
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a NestedScrollView's ScrollPosition access bug (#80573)
parent
ef7b6ffb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
6 deletions
+48
-6
nested_scroll_view.dart
packages/flutter/lib/src/widgets/nested_scroll_view.dart
+1
-6
nested_scroll_view_test.dart
packages/flutter/test/widgets/nested_scroll_view_test.dart
+47
-0
No files found.
packages/flutter/lib/src/widgets/nested_scroll_view.dart
View file @
cff3211f
...
...
@@ -1317,6 +1317,7 @@ class _NestedScrollController extends ScrollController {
@override
void
detach
(
ScrollPosition
position
)
{
assert
(
position
is
_NestedScrollPosition
);
(
position
as
_NestedScrollPosition
).
setParent
(
null
);
position
.
removeListener
(
_scheduleUpdateShadow
);
super
.
detach
(
position
);
_scheduleUpdateShadow
();
...
...
@@ -1621,12 +1622,6 @@ class _NestedScrollPosition extends ScrollPosition implements ScrollActivityDele
Drag
drag
(
DragStartDetails
details
,
VoidCallback
dragCancelCallback
)
{
return
coordinator
.
drag
(
details
,
dragCancelCallback
);
}
@override
void
dispose
()
{
_parent
?.
detach
(
this
);
super
.
dispose
();
}
}
enum
_NestedBallisticScrollActivityMode
{
outer
,
inner
,
independent
}
...
...
packages/flutter/test/widgets/nested_scroll_view_test.dart
View file @
cff3211f
...
...
@@ -2342,6 +2342,53 @@ void main() {
expect
(
isScrolled
,
false
);
expect
(
tester
.
takeException
(),
isNull
);
});
// Regression test of https://github.com/flutter/flutter/issues/74372
testWidgets
(
'ScrollPosition can be accessed during `_updatePosition()`'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
late
ScrollPosition
position
;
Widget
buildFrame
({
ScrollPhysics
?
physics
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
NestedScrollView
(
controller:
controller
,
physics:
physics
,
headerSliverBuilder:
(
BuildContext
context
,
bool
innerBoxIsScrolled
)
{
return
<
Widget
>[
Builder
(
builder:
(
BuildContext
context
)
{
position
=
controller
.
position
;
return
const
SliverAppBar
(
floating:
true
,
title:
Text
(
'AA'
),
);
},
),
];
},
body:
Container
(),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
());
expect
(
position
.
pixels
,
0.0
);
//Trigger `_updatePosition()`.
await
tester
.
pumpWidget
(
buildFrame
(
physics:
const
_CustomPhysics
()));
expect
(
position
.
pixels
,
0.0
);
});
}
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