-
Notifications
You must be signed in to change notification settings - Fork 29.7k
ShowCaretOnScreen is correctly scheduled within a SliverMainAxisGroup #141671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @yiiim thanks for contributing! I wonder, would overriding showOnScreen for RenderSliverMainAxisGroup be the right approach here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the viewport should not require a change here, since the issue lies in the sliver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the comment below here still be accurate with this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A user might request focus for a TextField that is located below an infinitely tall sliver (not limited to RenderSliverMainAxisGroup). Although this is a violation, it can be modified to an assertion here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share an example of that? An infinitely long sliver that precedes a text field would mean the text field is absolutely inaccessible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import 'package:flutter/material.dart';
FocusNode focusNode = FocusNode();
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: CustomScrollView(
slivers: [
SliverMainAxisGroup(
slivers: [
SliverList.builder(
itemBuilder: (context, index) {
return Container(
height: 44,
);
},
),
SliverToBoxAdapter(
child: TextField(
focusNode: focusNode,
),
),
],
),
],
),
floatingActionButton: IconButton(
onPressed: focusNode.requestFocus,
icon: const Icon(Icons.add),
),
),
);
}
}Like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to assert in the childScrollOffset method of SliverMainAxisGroup?
No, probably in RenderSliverMainAxisGroup.performLayout. It is not valid for a child of the group to have an infinite extent if there is another child following behind it. You would never be able to scroll to that following child.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! If the assertion is in RenderSliverMainAxisGroup.performLayout, then does RenderViewportBase.layoutChildSequence also need an assertion? It might not be appropriate to do this in this PR. Also, since English is not my native language, I might not be very good at providing debug messages. Could you please do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please do this?
Do you mean you would like to abandon this PR?
I can help with the error message from here on Github if you would like to add the assertion to RenderSliverMainAxisGroup.performLayout. :)
I don't think we should add the assertion to the viewport, since this issue is specific to the SliverMainAxisGroup. That is the issue we are trying to fix. If we have a case that supports adding it in the viewport, we should file a separate bug and PR so we can understand what that scenario is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very sorry, my translation may have caused some misunderstandings. I've added an assertion, please continue with the review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No apologies needed. Thank you for continuing to work on this! :)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this assertion necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ask because I wonder what this scenario is, and if we can catch it sooner in a place that would provide better context to the user in an error message to help debug. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, there is no better place to assert, and useful debugging messages cannot be provided here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the SliverMainAxisGroup assert its children have a finite extent if there are more children expected to follow in the group? That seems a better place to assert from. The issue would be coming from the group, not the whole viewport, which would probably be harder to debug.
|
May also solve #135407. |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May also solve #135407.
Can you verify if it does? If it does, we should add a test here that calls the method.
|
I have verified that it can fix #135407 and added tests for it. |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| offset += childLayoutGeometry.scrollExtent; | ||
| maxPaintExtent += child.geometry!.maxPaintExtent; | ||
| child = childAfter(child); | ||
| assert(() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is excellent!
Roll Flutter from d7867ca to 064c340 (33 revisions) flutter/flutter@d7867ca...064c340 2024-02-19 [email protected] Roll Flutter Engine from f71b7eee2266 to 714215d42e57 (1 revision) (flutter/flutter#143708) 2024-02-19 [email protected] Roll Flutter Engine from 07c73b0c8413 to f71b7eee2266 (2 revisions) (flutter/flutter#143694) 2024-02-19 [email protected] Roll Flutter Engine from 80d6745c6fd6 to 07c73b0c8413 (1 revision) (flutter/flutter#143682) 2024-02-19 [email protected] Roll Flutter Engine from 67abf6eb36a1 to 80d6745c6fd6 (1 revision) (flutter/flutter#143676) 2024-02-18 [email protected] Roll Flutter Engine from 8ae232196fc9 to 67abf6eb36a1 (1 revision) (flutter/flutter#143673) 2024-02-18 [email protected] Roll Flutter Engine from f636f9635438 to 8ae232196fc9 (1 revision) (flutter/flutter#143659) 2024-02-18 [email protected] Fixed the issue of incorrect item position when prototypeItem is set in SliverReorderableList. (flutter/flutter#142880) 2024-02-18 [email protected] ShowCaretOnScreen is correctly scheduled within a SliverMainAxisGroup (flutter/flutter#141671) 2024-02-18 [email protected] Roll Flutter Engine from 0ebd580cb8a7 to f636f9635438 (1 revision) (flutter/flutter#143657) 2024-02-17 [email protected] Roll Flutter Engine from c807aeaab89c to 0ebd580cb8a7 (1 revision) (flutter/flutter#143655) 2024-02-17 [email protected] Roll Flutter Engine from e51d4f1e285a to c807aeaab89c (4 revisions) (flutter/flutter#143652) 2024-02-17 [email protected] Manual roll Packages from c56c12d to 0af905d (flutter/flutter#143651) 2024-02-17 [email protected] Add an override annotation to the lineTerminator setter in the MemoryStdout fake class (flutter/flutter#143646) 2024-02-17 [email protected] InputDecorator M3 tests migration - Step3 (flutter/flutter#143520) 2024-02-17 [email protected] Update InputDecoration.contentPadding documentation (flutter/flutter#143519) 2024-02-17 [email protected] [Impeller] skip selectable text goldens for instability. (flutter/flutter#143627) 2024-02-17 [email protected] Roll Flutter Engine from 2ed159a786ef to e51d4f1e285a (2 revisions) (flutter/flutter#143624) 2024-02-17 [email protected] [Impeller] skip perspective transformed text goldens. (flutter/flutter#143623) 2024-02-17 [email protected] [framework] Skip 5 failing framework tests. (flutter/flutter#143618) 2024-02-17 [email protected] Roll Flutter Engine from afb270929a6c to 2ed159a786ef (1 revision) (flutter/flutter#143622) 2024-02-17 [email protected] Roll Flutter Engine from c4fe6f01e0f5 to afb270929a6c (1 revision) (flutter/flutter#143619) 2024-02-16 [email protected] Implement `lineTerminator` in `MemoryStdout` Fake (flutter/flutter#143608) 2024-02-16 [email protected] Roll Flutter Engine from 2eed3fbb293a to c4fe6f01e0f5 (3 revisions) (flutter/flutter#143615) 2024-02-16 [email protected] Don't paint the cursor for an invalid selection (flutter/flutter#143533) 2024-02-16 [email protected] Roll Flutter Engine from 13dc857bf2ef to 2eed3fbb293a (2 revisions) (flutter/flutter#143609) 2024-02-16 [email protected] Fix implementation imports outside of lib (flutter/flutter#143594) 2024-02-16 [email protected] add parsing of assets transformer declarations in pubspec.yaml (flutter/flutter#143557) 2024-02-16 [email protected] Roll Flutter Engine from 5fd5ccf32d08 to 13dc857bf2ef (6 revisions) (flutter/flutter#143607) 2024-02-16 [email protected] Fix SemanticsFinder for multi-view (flutter/flutter#143485) 2024-02-16 [email protected] rebuild the asset bundle if a file has been modified between `flutter test` runs (flutter/flutter#143569) 2024-02-16 [email protected] Added Missing Field Name in Doc Comment in SnackBarThemeData (flutter/flutter#143588) 2024-02-16 [email protected] Implementing `switch` expressions [refactoring `flutter/lib/src/`] (flutter/flutter#143496) 2024-02-16 [email protected] Roll Flutter Engine from dd530f1556df to 5fd5ccf32d08 (3 revisions) (flutter/flutter#143593) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: ...

Fixes #141577
Fixes #135407
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.