-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Handle#6537 end drawer button #173026
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
Handle#6537 end drawer button #173026
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 refactors the tests for BackButton and CloseButton into logical groups, which improves organization. It also adds a new test for EndDrawerButton to address issue #6537. The review focuses on improving the new test to ensure it correctly validates the intended fix and is more readable.
| testWidgets('EndDrawerButton renders at zero area', (WidgetTester tester) async { | ||
| await tester.pumpWidget( | ||
| const MaterialApp( | ||
| home: Material( | ||
| child: CloseButton( | ||
| color: Colors.green, | ||
| style: ButtonStyle(iconColor: MaterialStatePropertyAll<Color>(Colors.red)), | ||
| ), | ||
| home: Center( | ||
| child: SizedBox.shrink(child: Scaffold(body: EndDrawerButton())), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| final RichText iconText = tester.firstWidget( | ||
| find.descendant(of: find.byType(CloseButton), matching: find.byType(RichText)), | ||
| ); | ||
|
|
||
| expect(iconText.text.style!.color, Colors.red); | ||
| }); | ||
|
|
||
| testWidgets('CloseButton onPressed overrides default pop behavior', (WidgetTester tester) async { | ||
| bool customCallbackWasCalled = false; | ||
| await tester.pumpWidget( | ||
| MaterialApp( | ||
| home: const Material(child: Text('Home')), | ||
| routes: <String, WidgetBuilder>{ | ||
| '/next': (BuildContext context) { | ||
| return Material( | ||
| child: Center(child: CloseButton(onPressed: () => customCallbackWasCalled = true)), | ||
| ); | ||
| }, | ||
| }, | ||
| ), | ||
| ); | ||
|
|
||
| tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next'); | ||
|
|
||
| await tester.pumpAndSettle(); | ||
| expect(find.text('Home'), findsNothing); // Start off on the second page. | ||
| expect(customCallbackWasCalled, false); // customCallbackWasCalled should still be false. | ||
| await tester.tap(find.byType(CloseButton)); | ||
|
|
||
| await tester.pumpAndSettle(); | ||
|
|
||
| // We're still on the second page. | ||
| expect(find.text('Home'), findsNothing); | ||
| // The custom callback is called, setting customCallbackWasCalled to true. | ||
| expect(customCallbackWasCalled, true); | ||
| final Finder endDrawerButtonIcon = find.byType(EndDrawerButtonIcon); | ||
| expect(tester.getSize(endDrawerButtonIcon).isEmpty, isTrue); | ||
| }); |
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.
The test for EndDrawerButton does not fully address issue #6537, which involves an exception when no Scaffold ancestor is present. The current test includes a Scaffold, so it doesn't cover the scenario described in the issue. The use of SizedBox.shrink also reduces readability.
Consider adding a test case that explicitly checks the behavior when no Scaffold is present. Also, for consistency with the other tests in this file, wrap the EndDrawerButton test in a group to keep tests logically organized.1
group('EndDrawerButton', () {
testWidgets('does not throw without a Scaffold ancestor', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
// EndDrawerButton is not a descendant of a Scaffold.
home: Material(child: EndDrawerButton()),
),
);
// The test passes if it doesn't throw, and the button should not be visible.
expect(find.byType(IconButton), findsNothing);
});
});
Style Guide References
Footnotes
dkwingsmt
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.
LGTM
dkwingsmt
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.
Checklist:
- The test is in the correct file
- The test name goes “does not crash at zero area”
- The target widget is wrapped by
Center(or is fullscreen) - The target widget does not have an overlay, or the overlay is tested
- The target widget is expected to have a size of exactly
Size.zero
| testWidgets('CloseButton.style.iconColor parameter overrides CloseButton.color', ( | ||
| WidgetTester tester, | ||
| ) async { | ||
| testWidgets('EndDrawerButton renders at zero area', (WidgetTester tester) async { |
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.
| testWidgets('EndDrawerButton renders at zero area', (WidgetTester tester) async { | |
| testWidgets('EndDrawerButton does not crash at zero area', (WidgetTester tester) async { |
| final Finder endDrawerButtonIcon = find.byType(EndDrawerButtonIcon); | ||
| expect(tester.getSize(endDrawerButtonIcon).isEmpty, isTrue); |
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.
| final Finder endDrawerButtonIcon = find.byType(EndDrawerButtonIcon); | |
| expect(tester.getSize(endDrawerButtonIcon).isEmpty, isTrue); | |
| expect(tester.getSize(find.byType(EndDrawerButton)), Size.zero); |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
MitchellGoodwin
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.
LGTM as well
|
@ahmedsameha1 I am unable to rebase through github, would you be able to rebase this PR so it can merge? |
Manual roll Flutter from e11e2c1 to 7cd821c (73 revisions) Manual roll requested by tarrinneal@google.com flutter/flutter@e11e2c1...7cd821c 2025-10-14 bruno.leroux@gmail.com Fix computeDistanceToActualBaseline throws when accessing child size (flutter/flutter#176906) 2025-10-14 47866232+chunhtai@users.noreply.github.com iOS can set application locale before view controller is set (flutter/flutter#176592) 2025-10-14 jason-simmons@users.noreply.github.com Roll ANGLE to a branch based on d9fa255a5c22 (flutter/flutter#176747) 2025-10-14 47866232+chunhtai@users.noreply.github.com Relands "Fixes keyboard selects disabled radio" (flutter/flutter#176977) 2025-10-14 huy@nevercode.io Fix expansion tile is missing state announcement on non-Apple platforms (flutter/flutter#175480) 2025-10-14 30870216+gaaclarke@users.noreply.github.com impeller: allows access of float uniforms by name (flutter/flutter#176728) 2025-10-14 aam@google.com Roll dart sdk to 3.11.0-17.0.dev (flutter/flutter#176947) 2025-10-13 okorohelijah@google.com Move iOS integration tests (flutter/flutter#176940) 2025-10-13 ahmedsameha1@gmail.com Make sure that an InputDatePickerFormField doesn't crash in 0x0 envir… (flutter/flutter#176047) 2025-10-13 jason-simmons@users.noreply.github.com [web] Match the behavior of other platforms in Web Locale.toString if the country code is an empty string (flutter/flutter#176862) 2025-10-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fixes keyboard selects disabled radio (#176727)" (flutter/flutter#176958) 2025-10-13 47866232+chunhtai@users.noreply.github.com Fixes keyboard selects disabled radio (flutter/flutter#176727) 2025-10-13 engine-flutter-autoroll@skia.org Roll Packages from e319c40 to d062181 (2 revisions) (flutter/flutter#176916) 2025-10-13 jason-simmons@users.noreply.github.com Roll SwiftShader to 794b0cfce1d8 (flutter/flutter#176806) 2025-10-13 32538273+ValentinVignal@users.noreply.github.com Make DropdownMenu generic type non nullable (flutter/flutter#176711) 2025-10-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from BWGpRvpdQh-HJpq1c... to _dd0Jv50H0oUI2Ad8... (flutter/flutter#176895) 2025-10-11 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from JpiUsek1hU5r9QVKP... to BWGpRvpdQh-HJpq1c... (flutter/flutter#176880) 2025-10-11 codefu@google.com fix: content hash check for LUCI_CONTEXT (flutter/flutter#176867) 2025-10-11 34465683+rkishan516@users.noreply.github.com Feat: make tooltip position customizeable (flutter/flutter#175047) 2025-10-11 engine-flutter-autoroll@skia.org Roll Dart SDK from d88d8bf2b53c to 65b171958c93 (3 revisions) (flutter/flutter#176871) 2025-10-11 34465683+rkishan516@users.noreply.github.com feat: apply radioGroup role to segmented control widgets (flutter/flutter#176157) 2025-10-10 ahmedsameha1@gmail.com Make sure that a CheckboxMenuButton doesn't crash in 0x0 environment (flutter/flutter#176450) 2025-10-10 Rusino@users.noreply.github.com [WebParagraph] Support for more styles, placeholders, decorations, etc (flutter/flutter#172853) 2025-10-10 jason-simmons@users.noreply.github.com Set up a version of build_ios_framework_module_test that only runs on x64 machines and extend its timeout (flutter/flutter#176811) 2025-10-10 engine-flutter-autoroll@skia.org Roll Packages from 0b41de3 to e319c40 (1 revision) (flutter/flutter#176833) 2025-10-10 danny@tuppeny.com [tool/dap] Forward app.warning events from Flutter to DAP client (flutter/flutter#176827) 2025-10-10 engine-flutter-autoroll@skia.org Roll Dart SDK from 70c00d3ceb3a to d88d8bf2b53c (1 revision) (flutter/flutter#176830) 2025-10-10 sokolovskyi.konstantin@gmail.com Remove unnecessary nullable types in examples. (flutter/flutter#176713) 2025-10-10 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from xArtL4DH0FsdwSqG_... to JpiUsek1hU5r9QVKP... (flutter/flutter#176822) 2025-10-10 bruno.leroux@gmail.com Cleanup OutlinedButton.icon documentation and implementation (flutter/flutter#176630) 2025-10-10 34871572+gmackall@users.noreply.github.com [HCPP] Properly remove hcpp views that are no longer visible (flutter/flutter#176742) 2025-10-10 ahmedsameha1@gmail.com Make sure that an InputChip doesn't crash in 0x0 environment (flutter/flutter#175930) 2025-10-10 737941+loic-sharma@users.noreply.github.com Update Flutter templates' Dart style (flutter/flutter#175963) 2025-10-10 ahmedsameha1@gmail.com Make sure that a DropdownButtonFormField doesn't crash in 0x0 environ… (flutter/flutter#174958) 2025-10-10 ahmedsameha1@gmail.com Make sure that an InkWell doesn't crash in 0x0 environment (flutter/flutter#175871) 2025-10-10 ahmedsameha1@gmail.com Handle#6537 end drawer button (flutter/flutter#173026) 2025-10-10 engine-flutter-autoroll@skia.org Roll Dart SDK from a9b7bd4b0b32 to 70c00d3ceb3a (4 revisions) (flutter/flutter#176815) 2025-10-10 robert.ancell@canonical.com Change default Linux thread policy to merge platform and UI threads. (flutter/flutter#176759) 2025-10-09 bkonyi@google.com [ Tool ] Roll package:dwds to 26.0.0 (flutter/flutter#176808) 2025-10-09 43054281+camsim99@users.noreply.github.com Update `CHANGELOG` to include 3.35.6 notes (flutter/flutter#176803) 2025-10-09 36861262+QuncCccccc@users.noreply.github.com Announce text and button together when DropdownMenu is treated as a button (flutter/flutter#176428) 2025-10-09 gregorysconrad@gmail.com [native_assets] create macOS CCompilerConfig via xcrun --find (flutter/flutter#175717) 2025-10-09 chinmaygarde@google.com [Impeller] Fix broken links in README. (flutter/flutter#176770) 2025-10-09 chinmaygarde@google.com Fix links to Custom Flutter Engine Embedders in README. (flutter/flutter#175807) ...
This is my attempt to handle flutter#6537 for the EndDrawerButton UI control. --------- Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This is my attempt to handle #6537 for the EndDrawerButton UI control.