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
Conversation
@@ -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(), |
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.
Using const SizedBox.shrink(); Would be better.
See https://api.flutter.dev/flutter/widgets/Visibility-class.html
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.
@mahmoudsaleh1997 Agreed, thank you
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 a bunch for the contribution! Looking forward to getting this bug fixed.
child: widget.child!, | ||
child: widget.child ?? const SizedBox.shrink(), |
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.
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;
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.
@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 { |
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('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!
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.
@nate-thegrate Thank you for your review,i got it~
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 👍
Fantastic work here, thank you!
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.
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
Fix #147479
Pre-launch Checklist
If you need help, consider asking for advice on the #hackers-new channel on Discord.