• Taha Tesser's avatar
    Add `CheckedPopupMenuItem‎.labelTextStyle` and update default text style for Material 3 (#131060) · 038ec62b
    Taha Tesser authored
    fixes [Update `CheckedPopupMenuItem‎` for Material 3](https://github.com/flutter/flutter/issues/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" />
    038ec62b
Name
Last commit
Last update
..
flutter Loading commit data...
flutter_driver Loading commit data...
flutter_goldens Loading commit data...
flutter_goldens_client Loading commit data...
flutter_localizations Loading commit data...
flutter_test Loading commit data...
flutter_tools Loading commit data...
flutter_web_plugins Loading commit data...
fuchsia_remote_debug_protocol Loading commit data...
integration_test Loading commit data...
analysis_options.yaml Loading commit data...