Skip to content
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

fix MenuItemButton if child is null #147485

Merged
merged 7 commits into from May 7, 2024
Merged

Conversation

zeqinjie
Copy link
Contributor

@zeqinjie zeqinjie commented Apr 28, 2024

Fix #147479

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Apr 28, 2024
@zeqinjie zeqinjie changed the title fix 147479 fix MenuItemButton if child is null Apr 28, 2024
@@ -1141,7 +1141,7 @@ class _MenuItemButtonState extends State<MenuItemButton> {
trailingIcon: widget.trailingIcon,
hasSubmenu: false,
overflowAxis: _anchor?._orientation ?? widget.overflowAxis,
child: widget.child!,
child: widget.child ?? const SizedBox(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using const SizedBox.shrink(); Would be better.
See https://api.flutter.dev/flutter/widgets/Visibility-class.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mahmoudsaleh1997 Agreed, thank you

Copy link
Member

@nate-thegrate nate-thegrate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a bunch for the contribution! Looking forward to getting this bug fixed.

child: widget.child!,
child: widget.child ?? const SizedBox.shrink(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than just a one-line change here, would you be able to update _MenuItemLabel so it has a nullable child property? Currently it's still documented as being required:

const _MenuItemLabel({
  required this.hasSubmenu,
  this.showDecoration = true,
  this.leadingIcon,
  this.trailingIcon,
  this.shortcut,
  this.semanticsLabel,
  this.overflowAxis = Axis.vertical,
  required this.child,
});

/// The required label child widget.
final Widget child;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nate-thegrate Thank you for your review,i have updated~

@@ -2532,6 +2532,24 @@ void main() {
..rect(color: overlayColor.withOpacity(0.1)),
);
});

testWidgets('MenuItemButton is null check operator when it child is null', (WidgetTester tester) async {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
testWidgets('MenuItemButton is null check operator when it child is null', (WidgetTester tester) async {
testWidgets('MenuItemButton can build when its child is null', (WidgetTester tester) async {

The rest of this test looks fantastic!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nate-thegrate Thank you for your review,i got it~

Copy link
Member

@nate-thegrate nate-thegrate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Fantastic work here, thank you!

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label May 7, 2024
@auto-submit auto-submit bot merged commit 23ae246 into flutter:master May 7, 2024
72 checks passed
@zeqinjie zeqinjie deleted the fix_147479 branch May 7, 2024 07:13
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request May 7, 2024
flutter/flutter@04424e1...7920a52

2024-05-07 sokolovskyi.konstantin@gmail.com Add tests for callback_shortcuts.0.dart API example. (flutter/flutter#147536)
2024-05-07 barpac02@gmail.com Improve Android SDK and NDK mistmatch warning message (flutter/flutter#147809)
2024-05-07 sokolovskyi.konstantin@gmail.com Add tests for shortcuts.dart API examples. (flutter/flutter#147433)
2024-05-07 sosamaalirizvi@gmail.com Added missing tests for ButtonStyle example (flutter/flutter#147457)
2024-05-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from ece1d686e3ba to 150f694a7816 (1 revision) (flutter/flutter#147912)
2024-05-07 leroux_bruno@yahoo.fr DropdownMenu cleanup (flutter/flutter#147860)
2024-05-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from 80470584e1e1 to ece1d686e3ba (1 revision) (flutter/flutter#147910)
2024-05-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from b7bfd94af743 to 80470584e1e1 (1 revision) (flutter/flutter#147906)
2024-05-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from b64e2300bcd0 to b7bfd94af743 (1 revision) (flutter/flutter#147905)
2024-05-07 zeqinjie@qq.com fix MenuItemButton if child is null  (flutter/flutter#147485)
2024-05-07 gspencergoog@users.noreply.github.com Fix document generation, eliminate template support from snippets tool. (flutter/flutter#147893)
2024-05-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4cb9e02c06ce to b64e2300bcd0 (1 revision) (flutter/flutter#147904)
2024-05-07 82763757+NobodyForNothing@users.noreply.github.com test focus example 0 (flutter/flutter#147564)
2024-05-07 engine-flutter-autoroll@skia.org Roll Flutter Engine from 422f92b992c5 to 4cb9e02c06ce (1 revision) (flutter/flutter#147899)
2024-05-06 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#147896)
2024-05-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 463ff7d2d4d5 to 422f92b992c5 (5 revisions) (flutter/flutter#147895)
2024-05-06 59215665+davidhicks980@users.noreply.github.com MultiSelectableSelectionContainerDelegate documentation fixes. (flutter/flutter#147843)
2024-05-06 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#147891)
2024-05-06 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 4.1.4 to 4.1.5 (flutter/flutter#147888)
2024-05-06 32538273+ValentinVignal@users.noreply.github.com Fix janks and memory leaks in `CupertinoPageTransition` and `CupertinoFullscreenDialogTransition` (flutter/flutter#146999)
2024-05-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 960a0c8fecbe to 463ff7d2d4d5 (1 revision) (flutter/flutter#147886)
2024-05-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from 70cc300f9ad8 to 960a0c8fecbe (1 revision) (flutter/flutter#147884)
2024-05-06 jonahwilliams@google.com [new gallery] Reisze gallery images (flutter/flutter#147882)
2024-05-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from d0f99b35eac6 to 70cc300f9ad8 (1 revision) (flutter/flutter#147880)
2024-05-06 polinach@google.com Fix leak in a test. (flutter/flutter#147846)
2024-05-06 engine-flutter-autoroll@skia.org Roll Flutter Engine from a30ae7729c95 to d0f99b35eac6 (3 revisions) (flutter/flutter#147878)
2024-05-06 engine-flutter-autoroll@skia.org Roll Packages from f4719ca to 2dfe645 (3 revisions) (flutter/flutter#147866)

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 bmparr@google.com,rmistry@google.com,stuartmorgan@google.com 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MenuItemButton error if child is null
4 participants