• Taha Tesser's avatar
    Add delete button support to `FilterChip` (#136645) · 6c3010e7
    Taha Tesser authored
    fixes [`FilterChip` should have `DeletableChipAttributes`/`trailing` to match Material 3 spec.](https://github.com/flutter/flutter/issues/135595)
    
    ### 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 StatelessWidget {
      const Example({super.key});
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text('FilterChip'),
                const SizedBox(height: 8),
                FilterChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('FilterChip'),
                  selected: true,
                  showCheckmark: false,
                  onSelected: (bool value) {},
                  onDeleted: () {},
                  deleteButtonTooltipMessage: 'Delete Me!',
                ),
                const SizedBox(height: 16),
                FilterChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('FilterChip'),
                  onSelected: (bool value) {},
                  onDeleted: () {},
                ),
                const SizedBox(height: 48),
                const Text('FilterChip.elevated'),
                const SizedBox(height: 8),
                FilterChip.elevated(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('FilterChip'),
                  selected: true,
                  showCheckmark: false,
                  onSelected: (bool value) {},
                  onDeleted: () {},
                ),
                const SizedBox(height: 16),
                FilterChip.elevated(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('FilterChip'),
                  onSelected: (bool value) {},
                  onDeleted: () {},
                ),
              ],
            ),
          ),
        );
      }
    }
    ```
    
    </details>
    
    ### Before
    
    Not possible to add delete button
    
    ### After 
    ![Screenshot 2023-10-16 at 17 56 51](https://github.com/flutter/flutter/assets/48603081/ad751ef9-c2bc-4184-ae5f-4d1017eff664)
    6c3010e7
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...