• Taha Tesser's avatar
    Fix chip widgets don't the apply provided `iconTheme` (#135751) · f65dd3ba
    Taha Tesser authored
    fixes [`Chip.iconTheme` does not apply the icon theme](https://github.com/flutter/flutter/issues/111828)
    
    ### Description
    - Fix chip widgets that don't utilize the provided `iconTheme`.
    - Prevent `iconTheme` with just color from overriding the default icon size.
    - Add some missing M3 tests for the chip and chip theme properties.
    
    ### 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),
          home: const Example(),
        );
      }
    }
    
    class Example extends StatefulWidget {
      const Example({super.key});
    
      @override
      State<Example> createState() => _ExampleState();
    }
    
    class _ExampleState extends State<Example> {
      final bool _isEnable = true;
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                RawChip(
                  iconTheme: const IconThemeData(color: Colors.amber),
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('RawChip'),
                  onPressed: () {},
                  isEnabled: _isEnable,
                ),
                const Chip(
                  iconTheme: IconThemeData(color: Colors.amber),
                  avatar: Icon(Icons.favorite_rounded),
                  label: Text('Chip'),
                  // onDeleted: () {},
                ),
                FilterChip(
                  iconTheme: const IconThemeData(color: Colors.amber),
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('FilterChip'),
                  selected: false,
                  onSelected: _isEnable ? (bool value) {} : null,
                ),
                InputChip(
                  iconTheme: const IconThemeData(color: Colors.amber),
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('InputChip'),
                  isEnabled: _isEnable,
                  onPressed: () {},
                ),
                ActionChip(
                  iconTheme: const IconThemeData(color: Colors.amber),
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('ActionChip'),
                  onPressed: _isEnable ? () {} : null,
                ),
                ChoiceChip(
                  iconTheme: const IconThemeData(color: Colors.amber),
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('ChoiceChip'),
                  selected: false,
                  onSelected: _isEnable ? (bool value) {} : null,
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {},
            child: const Icon(Icons.add),
          ),
        );
      }
    }
    
    ```
    
    </details>
    
    ### Before
    ![Screenshot 2023-09-29 at 16 59 39](https://github.com/flutter/flutter/assets/48603081/4bc32032-cff3-4237-812f-86f17ed95337)
    
    ### After
    
    ![Screenshot 2023-09-29 at 16 55 24](https://github.com/flutter/flutter/assets/48603081/05a1fc52-fb31-4790-a840-18f2e9718241)
    f65dd3ba
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...
.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...