• Taha Tesser's avatar
    Fix Chips with Tooltip throw an assertion when enabling or disabling (#138799) · e6d43ac6
    Taha Tesser authored
    fixes [Enabling or disabling a `Chip`/`RawChip` with a tooltip throws an exception](https://github.com/flutter/flutter/issues/138287) 
    
    ### 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) {
        bool isEnabled = true;
    
        return MaterialApp(
          home: Material(
            child: Center(
              child: StatefulBuilder(
                  builder: (BuildContext context, StateSetter setState) {
                return Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    RawChip(
                      tooltip: 'This is a tooltip',
                      isEnabled: isEnabled,
                      label: const Text('RawChip'),
                      onPressed: isEnabled ? () {} : null,
                    ),
                    const SizedBox(height: 20),
                    ElevatedButton(
                      onPressed: () {
                        setState(() {
                          isEnabled = !isEnabled;
                        });
                      },
                      child: Text('${isEnabled ? 'Disable' : 'Enable'} Chip'),
                    )
                  ],
                );
              }),
            ),
          ),
        );
      }
    }
    ```
    
    </details>
    e6d43ac6
chip.dart 77 KB