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
e8812c40
Unverified
Commit
e8812c40
authored
Sep 29, 2020
by
Dan Field
Committed by
GitHub
Sep 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Improve the behavior of Scrollable.ensureVisible when Scrollable nested (#65226)" (#66918)
This reverts commit
73b63989
.
parent
9f481569
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
105 deletions
+3
-105
scroll_position.dart
packages/flutter/lib/src/widgets/scroll_position.dart
+3
-18
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+0
-10
ensure_visible_test.dart
packages/flutter/test/widgets/ensure_visible_test.dart
+0
-77
No files found.
packages/flutter/lib/src/widgets/scroll_position.dart
View file @
e8812c40
...
...
@@ -647,12 +647,6 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
/// Animates the position such that the given object is as visible as possible
/// by just scrolling this position.
///
/// The optional `targetRenderObject` parameter is used to determine which area
/// of that object should be as visible as possible. If `targetRenderObject` is null,
/// the entire [RenderObject] (as defined by its [RenderObject.paintBounds])
/// will be as visible as possible. If `targetRenderObject` is provided it should be
/// a descendant of the object.
///
/// See also:
///
/// * [ScrollPositionAlignmentPolicy] for the way in which `alignment` is
...
...
@@ -663,34 +657,25 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
Duration
duration
=
Duration
.
zero
,
Curve
curve
=
Curves
.
ease
,
ScrollPositionAlignmentPolicy
alignmentPolicy
=
ScrollPositionAlignmentPolicy
.
explicit
,
RenderObject
?
targetRenderObject
,
})
{
assert
(
alignmentPolicy
!=
null
);
assert
(
object
.
attached
);
final
RenderAbstractViewport
viewport
=
RenderAbstractViewport
.
of
(
object
)!;
assert
(
viewport
!=
null
);
Rect
?
targetRect
;
if
(
targetRenderObject
!=
null
)
{
targetRect
=
MatrixUtils
.
transformRect
(
targetRenderObject
.
getTransformTo
(
object
),
object
.
paintBounds
.
intersect
(
targetRenderObject
.
paintBounds
)
);
}
double
target
;
switch
(
alignmentPolicy
)
{
case
ScrollPositionAlignmentPolicy
.
explicit
:
target
=
viewport
.
getOffsetToReveal
(
object
,
alignment
,
rect:
targetRect
).
offset
.
clamp
(
minScrollExtent
,
maxScrollExtent
);
target
=
viewport
.
getOffsetToReveal
(
object
,
alignment
).
offset
.
clamp
(
minScrollExtent
,
maxScrollExtent
);
break
;
case
ScrollPositionAlignmentPolicy
.
keepVisibleAtEnd
:
target
=
viewport
.
getOffsetToReveal
(
object
,
1.0
,
rect:
targetRect
).
offset
.
clamp
(
minScrollExtent
,
maxScrollExtent
);
target
=
viewport
.
getOffsetToReveal
(
object
,
1.0
).
offset
.
clamp
(
minScrollExtent
,
maxScrollExtent
);
if
(
target
<
pixels
)
{
target
=
pixels
;
}
break
;
case
ScrollPositionAlignmentPolicy
.
keepVisibleAtStart
:
target
=
viewport
.
getOffsetToReveal
(
object
,
0.0
,
rect:
targetRect
).
offset
.
clamp
(
minScrollExtent
,
maxScrollExtent
);
target
=
viewport
.
getOffsetToReveal
(
object
,
0.0
).
offset
.
clamp
(
minScrollExtent
,
maxScrollExtent
);
if
(
target
>
pixels
)
{
target
=
pixels
;
}
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
e8812c40
...
...
@@ -307,13 +307,6 @@ class Scrollable extends StatefulWidget {
})
{
final
List
<
Future
<
void
>>
futures
=
<
Future
<
void
>>[];
// The `targetRenderObject` is used to record the first target renderObject.
// If there are multiple scrollable widgets nested, we should let
// the `targetRenderObject` as visible as possible to improve the user experience.
// Otherwise, let the outer renderObject as visible as possible maybe cause
// the `targetRenderObject` invisible.
// Also see https://github.com/flutter/flutter/issues/65100
RenderObject
?
targetRenderObject
;
ScrollableState
?
scrollable
=
Scrollable
.
of
(
context
);
while
(
scrollable
!=
null
)
{
futures
.
add
(
scrollable
.
position
.
ensureVisible
(
...
...
@@ -322,10 +315,7 @@ class Scrollable extends StatefulWidget {
duration:
duration
,
curve:
curve
,
alignmentPolicy:
alignmentPolicy
,
targetRenderObject:
targetRenderObject
,
));
targetRenderObject
=
targetRenderObject
??
context
.
findRenderObject
();
context
=
scrollable
.
context
;
scrollable
=
Scrollable
.
of
(
context
);
}
...
...
packages/flutter/test/widgets/ensure_visible_test.dart
View file @
e8812c40
...
...
@@ -224,83 +224,6 @@ void main() {
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
findKey
(
0
)).
dy
,
moreOrLessEquals
(
500.0
,
epsilon:
0.1
));
});
testWidgets
(
'Nested SingleChildScrollView ensureVisible behavior test'
,
(
WidgetTester
tester
)
async
{
// Regressing test for https://github.com/flutter/flutter/issues/65100
Finder
findKey
(
String
coordinate
)
=>
find
.
byKey
(
ValueKey
<
String
>(
coordinate
));
BuildContext
findContext
(
String
coordinate
)
=>
tester
.
element
(
findKey
(
coordinate
));
final
List
<
Row
>
rows
=
List
<
Row
>.
generate
(
7
,
(
int
y
)
=>
Row
(
children:
List
<
Container
>.
generate
(
7
,
(
int
x
)
=>
Container
(
key:
ValueKey
<
String
>(
'
$x
,
$y
'
),
width:
200.0
,
height:
200.0
,),
),
),
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
width:
600.0
,
height:
400.0
,
child:
SingleChildScrollView
(
scrollDirection:
Axis
.
horizontal
,
child:
SingleChildScrollView
(
scrollDirection:
Axis
.
vertical
,
child:
Column
(
children:
rows
,
),
),
),
),
),
),
);
// Items: 7 * 7 Container(width: 200.0, height: 200.0)
// viewport: Size(width: 600.0, height: 400.0)
//
// 0 600
// +----------------------+
// |0,0 |1,0 |2,0 |
// | | | |
// +----------------------+
// |0,1 |1,1 |2,1 |
// | | | |
// 400 +----------------------+
Scrollable
.
ensureVisible
(
findContext
(
'0, 0'
));
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
findKey
(
'0, 0'
)),
const
Offset
(
100.0
,
100.0
));
Scrollable
.
ensureVisible
(
findContext
(
'3, 0'
));
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
findKey
(
'3, 0'
)),
const
Offset
(
100.0
,
100.0
));
Scrollable
.
ensureVisible
(
findContext
(
'3, 0'
),
alignment:
0.5
);
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
findKey
(
'3, 0'
)),
const
Offset
(
300.0
,
100.0
));
Scrollable
.
ensureVisible
(
findContext
(
'6, 0'
));
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
findKey
(
'6, 0'
)),
const
Offset
(
500.0
,
100.0
));
Scrollable
.
ensureVisible
(
findContext
(
'0, 2'
));
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
findKey
(
'0, 2'
)),
const
Offset
(
100.0
,
100.0
));
Scrollable
.
ensureVisible
(
findContext
(
'3, 2'
));
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
findKey
(
'3, 2'
)),
const
Offset
(
100.0
,
100.0
));
// It should be at the center of the screen.
Scrollable
.
ensureVisible
(
findContext
(
'3, 2'
),
alignment:
0.5
);
await
tester
.
pump
();
expect
(
tester
.
getTopLeft
(
findKey
(
'3, 2'
)),
const
Offset
(
300.0
,
200.0
));
});
});
group
(
'ListView'
,
()
{
...
...
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