-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make sure that a Stepper doesn't crash in 0x0 environment #178068
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
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.
Code Review
This pull request adds a regression test for the Stepper widget. The new test case verifies that the Stepper does not crash when rendered within a zero-sized area by placing it inside a SizedBox.shrink() and asserting that its resulting size is Size.zero. This test addresses a previously reported crash scenario.
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.
Code Review
This pull request adds a regression test to ensure that the Stepper widget does not crash when rendered in a zero-sized environment. The added test covers the default vertical stepper. My review includes a suggestion to enhance the test to cover both vertical and horizontal stepper types for better test coverage, especially since the original issue was related to the horizontal stepper.
| testWidgets('Stepper does not crash at zero area', (WidgetTester tester) async { | ||
| await tester.pumpWidget( | ||
| MaterialApp( | ||
| home: Scaffold( | ||
| body: Center( | ||
| child: SizedBox.shrink( | ||
| child: Stepper( | ||
| steps: const <Step>[ | ||
| Step(title: Text('X'), content: Text('X')), | ||
| Step(title: Text('Y'), content: Text('Y')), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(Stepper)), Size.zero); | ||
| }); |
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 test only covers the default vertical Stepper. The original issue this PR is addressing was about the horizontal Stepper. It would be better to test both types. This can be done by iterating over StepperType.values.
testWidgets('Stepper does not crash at zero area', (WidgetTester tester) async {
for (final StepperType type in StepperType.values) {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: SizedBox.shrink(
child: Stepper(
type: type,
steps: const <Step>[
Step(title: Text('X'), content: Text('X')),
Step(title: Text('Y'), content: Text('Y')),
],
),
),
),
),
),
);
expect(tester.getSize(find.byType(Stepper)), Size.zero);
}
});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.
+1
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.
Code Review
This pull request adds a regression test to ensure the Stepper widget doesn't crash when placed in a zero-sized environment. The test is well-written, but it only covers the vertical Stepper. I've added a suggestion to also test the horizontal Stepper to make the test more comprehensive, as its layout logic is different and could have similar issues. Apart from that, the PR looks good.
| testWidgets('Stepper does not crash at zero area', (WidgetTester tester) async { | ||
| await tester.pumpWidget( | ||
| MaterialApp( | ||
| home: Scaffold( | ||
| body: Center( | ||
| child: SizedBox.shrink( | ||
| child: Stepper( | ||
| steps: const <Step>[ | ||
| Step(title: Text('X'), content: Text('X')), | ||
| Step(title: Text('Y'), content: Text('Y')), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(Stepper)), Size.zero); | ||
| }); |
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 test is great for ensuring the Stepper doesn't crash in a zero-sized environment. However, it only covers the default StepperType.vertical. The horizontal stepper has a different layout structure which could also be prone to issues in a 0x0 environment. To make the test more comprehensive, I suggest testing both StepperType.vertical and StepperType.horizontal. You can do this by iterating over StepperType.values.
testWidgets('Stepper does not crash at zero area', (WidgetTester tester) async {
for (final StepperType type in StepperType.values) {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: SizedBox.shrink(
child: Stepper(
type: type,
steps: const <Step>[
Step(title: Text('X'), content: Text('X')),
Step(title: Text('Y'), content: Text('Y')),
],
),
),
),
),
),
);
expect(tester.getSize(find.byType(Stepper)), Size.zero, reason: 'for StepperType.$type');
}
});|
autosubmit label was removed for flutter/flutter/178068, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
|
autosubmit label was removed for flutter/flutter/178068, because - The status or check suite Mac customer_testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
flutter/flutter@d438df3...c8cfb2b 2025-11-22 [email protected] Revert "[ios] Dynamic Content Resizing" (flutter/flutter#178958) 2025-11-22 [email protected] Make sure that a SearchAnchor doesn't crash in 0x0 environment (flutter/flutter#177749) 2025-11-22 [email protected] Make sure that a Stepper doesn't crash in 0x0 environment (flutter/flutter#178068) 2025-11-22 [email protected] Remove deprecated `activeColor` in `switch.0.dart` example (flutter/flutter#178293) 2025-11-22 [email protected] Make sure that a UserAccountsDrawerHeader doesn't crash in 0x0 enviro… (flutter/flutter#178516) 2025-11-22 [email protected] Make sure that a TimePickerDialog doesn't crash in 0x0 environment (flutter/flutter#178451) 2025-11-22 [email protected] Make sure that a CupertinoLinearActivityIndicator doesn't crash in 0x… (flutter/flutter#178566) 2025-11-22 [email protected] Make sure that a CupertinoTabBar doesn't crash in 0x0 environment (flutter/flutter#178613) 2025-11-22 [email protected] Make sure that a CupertinoContextMenu doesn't crash in 0x0 environment (flutter/flutter#178722) 2025-11-22 [email protected] Sort entries in TESTOWNERS (flutter/flutter#178939) 2025-11-22 [email protected] [ios] Dynamic Content Resizing (flutter/flutter#177410) 2025-11-21 [email protected] Roll Skia from dc88b21ce7d2 to 3018c3053490 (2 revisions) (flutter/flutter#178947) 2025-11-21 [email protected] Manually roll material_color_utilities (flutter/flutter#170000) 2025-11-21 [email protected] Roll Fuchsia Linux SDK from Y-cMdgKy3d6EnibWR... to 4ul9jvZ7jnDGIjtCD... (flutter/flutter#178934) 2025-11-21 [email protected] Roll Dart SDK from c788b6a7aefd to 5af71c736b0a (1 revision) (flutter/flutter#178932) 2025-11-21 [email protected] Roll Skia from c588bb60d5da to dc88b21ce7d2 (2 revisions) (flutter/flutter#178933) 2025-11-21 [email protected] Update .ci.yaml and TESTOWNERS for arc macrobenchmark tests (flutter/flutter#178891) 2025-11-21 [email protected] Use interactive mode with `devicectl` to redirect stdout (flutter/flutter#178405) 2025-11-21 [email protected] Update .ci.yaml in flutter/flutter to use either macOS 15.5 or macOS … (flutter/flutter#178666) 2025-11-21 [email protected] Roll Skia from d4e9d2873bfd to c588bb60d5da (1 revision) (flutter/flutter#178928) 2025-11-21 [email protected] Roll Packages from b1e2fb0 to e67b6be (7 revisions) (flutter/flutter#178927) 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] 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: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…8068) This is my attempt to handle flutter#6537 for the Stepper widget. --------- Co-authored-by: Victor Sanni <[email protected]> Co-authored-by: Tong Mu <[email protected]>
…8068) This is my attempt to handle flutter#6537 for the Stepper widget. --------- Co-authored-by: Victor Sanni <[email protected]> Co-authored-by: Tong Mu <[email protected]>
This is my attempt to handle #6537 for the Stepper widget.