• Taha Tesser's avatar
    Fix chips `onDeleted` callback don't show the delete button when disabled (#137685) · 4648f544
    Taha Tesser authored
    fixes [Chips with `onDeleted` callback should show the delete button in the `disabled` state](https://github.com/flutter/flutter/issues/136638)
    
    ### 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 const MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Example(),
        );
      }
    }
    
    class Example extends StatefulWidget {
      const Example({super.key});
    
      @override
      State<Example> createState() => _ExampleState();
    }
    
    class _ExampleState extends State<Example> {
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                RawChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('RawChip'),
                  onSelected: null,
                  isEnabled: false,
                  onDeleted: () {},
                ),
                InputChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('InputChip'),
                  isEnabled: false,
                  onPressed: null,
                  onDeleted: () {},
                ),
                FilterChip(
                  avatar: const Icon(Icons.favorite_rounded),
                  label: const Text('FilterChip'),
                  onSelected: null,
                  onDeleted: () {},
                ),
              ],
            ),
          ),
        );
      }
    }
    ```
    
    </details>
    
    | Before | After |
    | --------------- | --------------- |
    | <img src="https://github.com/flutter/flutter/assets/48603081/8bd458de-cfd2-44f0-a0dd-a8298938c61f" /> | <img src="https://github.com/flutter/flutter/assets/48603081/afca0684-b061-416b-b029-5316588c6888" /> |
    4648f544
chip_test.dart 141 KB