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
bac5a0db
Unverified
Commit
bac5a0db
authored
May 18, 2021
by
xubaolin
Committed by
GitHub
May 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix scrollable widget scrollDirection update bug (#82025)
parent
a3863b65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletion
+48
-1
scroll_position.dart
packages/flutter/lib/src/widgets/scroll_position.dart
+4
-1
viewport_test.dart
packages/flutter/test/rendering/viewport_test.dart
+44
-0
No files found.
packages/flutter/lib/src/widgets/scroll_position.dart
View file @
bac5a0db
...
...
@@ -506,6 +506,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
bool
_pendingDimensions
=
false
;
ScrollMetrics
?
_lastMetrics
;
Axis
?
_lastAxis
;
@override
bool
applyContentDimensions
(
double
minScrollExtent
,
double
maxScrollExtent
)
{
...
...
@@ -514,12 +515,14 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
assert
(
haveDimensions
==
(
_lastMetrics
!=
null
));
if
(!
nearEqual
(
_minScrollExtent
,
minScrollExtent
,
Tolerance
.
defaultTolerance
.
distance
)
||
!
nearEqual
(
_maxScrollExtent
,
maxScrollExtent
,
Tolerance
.
defaultTolerance
.
distance
)
||
_didChangeViewportDimensionOrReceiveCorrection
)
{
_didChangeViewportDimensionOrReceiveCorrection
||
_lastAxis
!=
axis
)
{
assert
(
minScrollExtent
!=
null
);
assert
(
maxScrollExtent
!=
null
);
assert
(
minScrollExtent
<=
maxScrollExtent
);
_minScrollExtent
=
minScrollExtent
;
_maxScrollExtent
=
maxScrollExtent
;
_lastAxis
=
axis
;
final
ScrollMetrics
?
currentMetrics
=
haveDimensions
?
copyWith
()
:
null
;
_didChangeViewportDimensionOrReceiveCorrection
=
false
;
_pendingDimensions
=
true
;
...
...
packages/flutter/test/rendering/viewport_test.dart
View file @
bac5a0db
...
...
@@ -45,6 +45,50 @@ class _TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate
}
void
main
(
)
{
testWidgets
(
'Scrollable widget scrollDirection update test'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
Widget
buildFrame
(
Axis
axis
)
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
height:
100.0
,
width:
100.0
,
child:
SingleChildScrollView
(
controller:
controller
,
scrollDirection:
axis
,
child:
const
SizedBox
(
width:
200
,
height:
200
,
child:
SizedBox
.
shrink
(),
),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
Axis
.
vertical
));
expect
(
controller
.
position
.
pixels
,
0.0
);
// Change the SingleChildScrollView.scrollDirection to horizontal.
await
tester
.
pumpWidget
(
buildFrame
(
Axis
.
horizontal
));
expect
(
controller
.
position
.
pixels
,
0.0
);
final
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Offset
(
400.0
,
300.0
));
// Drag in the vertical direction should not cause scrolling.
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
10.0
));
expect
(
controller
.
position
.
pixels
,
0.0
);
await
gesture
.
moveBy
(
const
Offset
(
0.0
,
-
10.0
));
expect
(
controller
.
position
.
pixels
,
0.0
);
// Drag in the horizontal direction should cause scrolling.
await
gesture
.
moveBy
(
const
Offset
(-
10.0
,
0.0
));
expect
(
controller
.
position
.
pixels
,
10.0
);
await
gesture
.
moveBy
(
const
Offset
(
10.0
,
0.0
));
expect
(
controller
.
position
.
pixels
,
0.0
);
});
testWidgets
(
'Viewport getOffsetToReveal - down'
,
(
WidgetTester
tester
)
async
{
List
<
Widget
>
children
;
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