-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add CheckedPopupMenuItem.labelTextStyle and update default text style for Material 3
#131060
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
Add CheckedPopupMenuItem.labelTextStyle and update default text style for Material 3
#131060
Conversation
…yle for Material 3
HansMuller
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
|
@TahaTesser and @HansMuller, interesting find and fix with the This got me to look closer at the M3 spec for the text in menus. I had not noticed it, but yes indeed M3 spec calls for All the new M3 menus, like The only place where new menus have actually used I had wrongly assumed that the
This is a bit of dilemma, on one side it is M3 spec, on the other side changing this wrong default now is also breaking. Not that I personally mind, I'm just stating that it will be breaking to update the default for many apps, to now follow the correct M3 spec. This of course argues for continuing to use I discussed the deviation of the I did however not raise an issue about it, but it does kind feel like it should be an issue of its own now. Personally I like when the input field in the One could of course also argue that EDIT: If we look at Jetpack Compose and what a This means that Flutter basically has its |
… text style for Material 3 (flutter/flutter#131060)
… text style for Material 3 (flutter/flutter#131060)
flutter/flutter@e81907e...c2b40ca 2023-07-29 [email protected] Roll Flutter Engine from 24ccd8fffbcb to 5184062f7543 (2 revisions) (flutter/flutter#131554) 2023-07-29 [email protected] Roll Flutter Engine from 90bc483524fe to 24ccd8fffbcb (1 revision) (flutter/flutter#131540) 2023-07-29 [email protected] Roll Flutter Engine from 27128f29a066 to 90bc483524fe (2 revisions) (flutter/flutter#131535) 2023-07-29 [email protected] Roll Flutter Engine from 69b5b77edaf7 to 27128f29a066 (1 revision) (flutter/flutter#131533) 2023-07-29 [email protected] Roll Flutter Engine from b854fdea2715 to 69b5b77edaf7 (1 revision) (flutter/flutter#131532) 2023-07-29 [email protected] Roll Flutter Engine from 0a5b2f521539 to b854fdea2715 (1 revision) (flutter/flutter#131530) 2023-07-29 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 2.21.0 to 2.21.2 (flutter/flutter#131512) 2023-07-29 [email protected] Roll Flutter Engine from f5c17f0e2406 to 0a5b2f521539 (2 revisions) (flutter/flutter#131529) 2023-07-29 [email protected] Roll Flutter Engine from b4bf592279d6 to f5c17f0e2406 (1 revision) (flutter/flutter#131525) 2023-07-28 [email protected] Roll Flutter Engine from da3721adba65 to b4bf592279d6 (2 revisions) (flutter/flutter#131519) 2023-07-28 [email protected] Roll Flutter Engine from aa1278eb7b84 to da3721adba65 (5 revisions) (flutter/flutter#131514) 2023-07-28 [email protected] Reland - Fix floating SnackBar throws when FAB is on the top (flutter/flutter#131475) 2023-07-28 [email protected] Device discovery output cleanup (flutter/flutter#131223) 2023-07-28 [email protected] Roll Flutter Engine from 182e1189873b to aa1278eb7b84 (2 revisions) (flutter/flutter#131500) 2023-07-28 [email protected] Update `BottomSheet.enableDrag` & `BottomSheet.showDragHandle` docs for animation controller (flutter/flutter#131484) 2023-07-28 [email protected] Deprecate `useMaterial3` parameter in `ThemeData.copyWith()` (flutter/flutter#131455) 2023-07-28 [email protected] Roll Flutter Engine from 73615d66b2fe to 182e1189873b (2 revisions) (flutter/flutter#131492) 2023-07-28 [email protected] Add `CheckedPopupMenuItem�.labelTextStyle` and update default text style for Material 3 (flutter/flutter#131060) 2023-07-28 [email protected] Remove obsolete `complex_layout_ios__compile.dart` test (flutter/flutter#131487) 2023-07-28 [email protected] Roll Flutter Engine from e97014c71014 to 73615d66b2fe (3 revisions) (flutter/flutter#131485) 2023-07-28 [email protected] Shared state to support multi screen inspection (flutter/flutter#129452) 2023-07-28 [email protected] Roll Packages from f4ae933 to 10aab44 (4 revisions) (flutter/flutter#131483) 2023-07-28 [email protected] Move ios_app_with_extensions_test to host only (flutter/flutter#131441) 2023-07-28 [email protected] Update `Card.color` documentation for Material 3 (flutter/flutter#131468) 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…yle for Material 3 (flutter#131060) fixes [Update `CheckedPopupMenuItemâ��` for Material 3](flutter#128576) ### Description - This adds the missing ``CheckedPopupMenuItemâ��.labelTextStyle` parameter - Fixes default text style for `CheckedPopupMenuItemâ��`. It used `ListTile`'s `bodyLarge` instead of `LabelLarge` similar to `PopupMenuItem`. ### Code sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @OverRide Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( useMaterial3: true, textTheme: const TextTheme( labelLarge: TextStyle( fontWeight: FontWeight.bold, fontStyle: FontStyle.italic, letterSpacing: 5.0, ), ), ), home: const Example(), ); } } class Example extends StatelessWidget { const Example({super.key}); @OverRide Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Sample'), actions: <Widget>[ PopupMenuButton<String>( icon: const Icon(Icons.more_vert), itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ const CheckedPopupMenuItem<String>( // labelTextStyle: MaterialStateProperty.resolveWith( // (Set<MaterialState> states) { // if (states.contains(MaterialState.selected)) { // return const TextStyle( // color: Colors.red, // fontStyle: FontStyle.italic, // fontWeight: FontWeight.bold, // ); // } // return const TextStyle( // color: Colors.amber, // fontStyle: FontStyle.italic, // fontWeight: FontWeight.bold, // ); // }), child: Text('Mild'), ), const CheckedPopupMenuItem<String>( checked: true, // labelTextStyle: MaterialStateProperty.resolveWith( // (Set<MaterialState> states) { // if (states.contains(MaterialState.selected)) { // return const TextStyle( // color: Colors.red, // fontStyle: FontStyle.italic, // fontWeight: FontWeight.bold, // ); // } // return const TextStyle( // color: Colors.amber, // fontStyle: FontStyle.italic, // fontWeight: FontWeight.bold, // ); // }), child: Text('Spicy'), ), const PopupMenuDivider(), const PopupMenuItem<String>( value: 'Close', child: Text('Close'), ), ], ) ], ), ); } } ``` </details> ### Customized `textTheme.labelLarge` text theme. | Before | After | | --------------- | --------------- | | <img src="https://github.com/flutter/flutter/assets/48603081/2672438d-b2da-479b-a5d3-d239ef646365" /> | <img src="https://github.com/flutter/flutter/assets/48603081/b9f83719-dede-4c2f-8247-18f74e63eb29" /> | ### New `CheckedPopupMenuItemâ��.labelTextStyle` parameter with material states support <img src="https://github.com/flutter/flutter/assets/48603081/ef0a88aa-9811-42b1-a3aa-53b90c8d43fb" height="450" />
…yle for Material 3 (flutter#131060) fixes [Update `CheckedPopupMenuItemâ��` for Material 3](flutter#128576) ### Description - This adds the missing ``CheckedPopupMenuItemâ��.labelTextStyle` parameter - Fixes default text style for `CheckedPopupMenuItemâ��`. It used `ListTile`'s `bodyLarge` instead of `LabelLarge` similar to `PopupMenuItem`. ### Code sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @OverRide Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( useMaterial3: true, textTheme: const TextTheme( labelLarge: TextStyle( fontWeight: FontWeight.bold, fontStyle: FontStyle.italic, letterSpacing: 5.0, ), ), ), home: const Example(), ); } } class Example extends StatelessWidget { const Example({super.key}); @OverRide Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Sample'), actions: <Widget>[ PopupMenuButton<String>( icon: const Icon(Icons.more_vert), itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ const CheckedPopupMenuItem<String>( // labelTextStyle: MaterialStateProperty.resolveWith( // (Set<MaterialState> states) { // if (states.contains(MaterialState.selected)) { // return const TextStyle( // color: Colors.red, // fontStyle: FontStyle.italic, // fontWeight: FontWeight.bold, // ); // } // return const TextStyle( // color: Colors.amber, // fontStyle: FontStyle.italic, // fontWeight: FontWeight.bold, // ); // }), child: Text('Mild'), ), const CheckedPopupMenuItem<String>( checked: true, // labelTextStyle: MaterialStateProperty.resolveWith( // (Set<MaterialState> states) { // if (states.contains(MaterialState.selected)) { // return const TextStyle( // color: Colors.red, // fontStyle: FontStyle.italic, // fontWeight: FontWeight.bold, // ); // } // return const TextStyle( // color: Colors.amber, // fontStyle: FontStyle.italic, // fontWeight: FontWeight.bold, // ); // }), child: Text('Spicy'), ), const PopupMenuDivider(), const PopupMenuItem<String>( value: 'Close', child: Text('Close'), ), ], ) ], ), ); } } ``` </details> ### Customized `textTheme.labelLarge` text theme. | Before | After | | --------------- | --------------- | | <img src="https://github.com/flutter/flutter/assets/48603081/2672438d-b2da-479b-a5d3-d239ef646365" /> | <img src="https://github.com/flutter/flutter/assets/48603081/b9f83719-dede-4c2f-8247-18f74e63eb29" /> | ### New `CheckedPopupMenuItemâ��.labelTextStyle` parameter with material states support <img src="https://github.com/flutter/flutter/assets/48603081/ef0a88aa-9811-42b1-a3aa-53b90c8d43fb" height="450" />

fixes Update
CheckedPopupMenuItemfor Material 3Description
CheckedPopupMenuItem.It used
ListTile'sbodyLargeinstead ofLabelLargesimilar toPopupMenuItem.Code sample
expand to view the code sample
Customized
textTheme.labelLargetext theme.New
CheckedPopupMenuItem.labelTextStyleparameter with material states supportPre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.