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
73c26a1c
Unverified
Commit
73c26a1c
authored
Feb 18, 2024
by
yim
Committed by
GitHub
Feb 18, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ShowCaretOnScreen is correctly scheduled within a SliverMainAxisGroup (#141671)
Fixes #141577 Fixes #135407
parent
deaf53ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
sliver_group.dart
packages/flutter/lib/src/rendering/sliver_group.dart
+33
-0
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+38
-0
sliver_main_axis_group_test.dart
...ges/flutter/test/widgets/sliver_main_axis_group_test.dart
+17
-0
No files found.
packages/flutter/lib/src/rendering/sliver_group.dart
View file @
73c26a1c
...
...
@@ -203,6 +203,30 @@ class RenderSliverMainAxisGroup extends RenderSliver with ContainerRenderObjectM
}
}
@override
double
?
childScrollOffset
(
RenderObject
child
)
{
assert
(
child
.
parent
==
this
);
final
GrowthDirection
growthDirection
=
constraints
.
growthDirection
;
switch
(
growthDirection
)
{
case
GrowthDirection
.
forward
:
double
childScrollOffset
=
0.0
;
RenderSliver
?
current
=
childBefore
(
child
as
RenderSliver
);
while
(
current
!=
null
)
{
childScrollOffset
+=
current
.
geometry
!.
scrollExtent
;
current
=
childBefore
(
current
);
}
return
childScrollOffset
;
case
GrowthDirection
.
reverse
:
double
childScrollOffset
=
0.0
;
RenderSliver
?
current
=
childAfter
(
child
as
RenderSliver
);
while
(
current
!=
null
)
{
childScrollOffset
-=
current
.
geometry
!.
scrollExtent
;
current
=
childAfter
(
current
);
}
return
childScrollOffset
;
}
}
@override
double
childMainAxisPosition
(
RenderSliver
child
)
{
switch
(
constraints
.
axisDirection
)
{
...
...
@@ -254,6 +278,15 @@ class RenderSliverMainAxisGroup extends RenderSliver with ContainerRenderObjectM
offset
+=
childLayoutGeometry
.
scrollExtent
;
maxPaintExtent
+=
child
.
geometry
!.
maxPaintExtent
;
child
=
childAfter
(
child
);
assert
(()
{
if
(
child
!=
null
&&
maxPaintExtent
.
isInfinite
)
{
throw
FlutterError
(
'Unreachable sliver found, you may have a sliver behind '
'a sliver with infinite extent. '
);
}
return
true
;
}());
}
final
double
totalScrollExtent
=
offset
;
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
73c26a1c
...
...
@@ -17101,6 +17101,44 @@ void main() {
await
tester
.
pumpAndSettle
();
expect
(
notifyCount
,
equals
(
1
));
});
testWidgets
(
'ShowCaretOnScreen is correctly scheduled within a SliverMainAxisGroup'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
scrollController
=
ScrollController
();
addTearDown
(
scrollController
.
dispose
);
final
Widget
widget
=
MaterialApp
(
home:
Scaffold
(
body:
CustomScrollView
(
controller:
scrollController
,
slivers:
const
<
Widget
>[
SliverMainAxisGroup
(
slivers:
<
Widget
>[
SliverToBoxAdapter
(
child:
SizedBox
(
height:
600
,
),
),
SliverToBoxAdapter
(
child:
SizedBox
(
height:
44
,
child:
TextField
(),
),
),
SliverToBoxAdapter
(
child:
SizedBox
(
height:
500
,
),
),
],
)
],
),
),
);
await
tester
.
pumpWidget
(
widget
);
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
pumpAndSettle
();
expect
(
scrollController
.
offset
,
75.0
);
});
}
class
UnsettableController
extends
TextEditingController
{
...
...
packages/flutter/test/widgets/sliver_main_axis_group_test.dart
View file @
73c26a1c
...
...
@@ -728,6 +728,23 @@ void main() {
)
as
RenderSliverMainAxisGroup
;
expect
(
renderGroup
.
geometry
!.
cacheExtent
,
850.0
);
});
testWidgets
(
'SliverMainAxisGroup correctly handles ensureVisible'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
_buildSliverMainAxisGroup
(
viewportHeight:
300
,
slivers:
<
Widget
>[
const
SliverToBoxAdapter
(
child:
SizedBox
(
height:
300
)),
SliverToBoxAdapter
(
child:
SizedBox
(
key:
key
,
height:
100
)),
const
SliverToBoxAdapter
(
child:
SizedBox
(
height:
300
)),
]
)
);
Scrollable
.
ensureVisible
(
key
.
currentContext
!);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
key
)),
Offset
.
zero
);
});
}
Widget
_buildSliverList
(
{
...
...
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