• Taha Tesser's avatar
    Add `PopupMenuButton.iconColor`, `PopupMenuTheme.iconSize` and fix button icon... · b77b149d
    Taha Tesser authored
    Add `PopupMenuButton.iconColor`, `PopupMenuTheme.iconSize` and fix button icon using unexpected color propert (#132054)
    
    fixes [PopupMenuButton uses color property for icon color](https://github.com/flutter/flutter/issues/127802) 
    fixes [`popup_menu_test.dart` lacks default icon color tests.](https://github.com/flutter/flutter/issues/132050) 
    
    ### Description
    - Add  `PopupMenuButton..iconColor` and fix the PopupMenu button icon using an unexpected color property.
    - Add the missing `PopupMenuTheme.iconSize`.
    - Clean up some tests and minor improvements.
    
    ### Code sample
    
    <details> 
    <summary>expand to view the code sample</summary> 
    
    ```dart
    import 'package:flutter/material.dart';
    
    /// Flutter code sample for [PopupMenuButton].
    
    // This is the type used by the popup menu below.
    enum SampleItem { itemOne, itemTwo, itemThree }
    
    void main() => runApp(const PopupMenuApp());
    
    class PopupMenuApp extends StatelessWidget {
      const PopupMenuApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          theme: ThemeData(
            popupMenuTheme: PopupMenuThemeData(
              // iconSize: 75,
              // iconColor: Colors.amber,
              color: Colors.deepPurple[100],
            ),
          ),
          home: const PopupMenuExample(),
        );
      }
    }
    
    class PopupMenuExample extends StatefulWidget {
      const PopupMenuExample({super.key});
    
      @override
      State<PopupMenuExample> createState() => _PopupMenuExampleState();
    }
    
    class _PopupMenuExampleState extends State<PopupMenuExample> {
      SampleItem? selectedMenu;
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: const Text('PopupMenuButton')),
          body: Center(
            child: PopupMenuButton<SampleItem>(
              iconSize: 75,
              // iconColor: Colors.amber,
              color: Colors.deepPurple[100],
              initialValue: selectedMenu,
              // Callback that sets the selected popup menu item.
              onSelected: (SampleItem item) {
                setState(() {
                  selectedMenu = item;
                });
              },
              itemBuilder: (BuildContext context) => <PopupMenuEntry<SampleItem>>[
                const PopupMenuItem<SampleItem>(
                  value: SampleItem.itemOne,
                  child: Text('Item 1'),
                ),
                const PopupMenuItem<SampleItem>(
                  value: SampleItem.itemTwo,
                  child: Text('Item 2'),
                ),
                const PopupMenuDivider(),
                const CheckedPopupMenuItem<SampleItem>(
                  value: SampleItem.itemThree,
                  checked: true,
                  child: Text('Item 3'),
                ),
              ],
            ),
          ),
        );
      }
    }
    
    ``` 
    	
    </details>
    
    ![Group 2](https://github.com/flutter/flutter/assets/48603081/eb5404ae-2a07-4374-9821-66a0bbea041e)
    
    ![Group 1](https://github.com/flutter/flutter/assets/48603081/464e3957-1afb-4118-abcc-aad12591dc51)
    b77b149d
Name
Last commit
Last update
.github Loading commit data...
.vscode Loading commit data...
bin Loading commit data...
dev Loading commit data...
examples Loading commit data...
packages Loading commit data...
.ci.yaml Loading commit data...
.cirrus.yml Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CODEOWNERS Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
PATENT_GRANT Loading commit data...
README.md Loading commit data...
TESTOWNERS Loading commit data...
analysis_options.yaml Loading commit data...
dartdoc_options.yaml Loading commit data...
flutter_console.bat Loading commit data...