• Taha Tesser's avatar
    Fix disabled `DropdownMenu` doesn't defer the mouse cursor (#145686) · d2c85529
    Taha Tesser authored
    fixes [DropdownMenu cursor in disabled state](https://github.com/flutter/flutter/issues/144611)
    
    This was added in https://github.com/flutter/flutter/pull/121353
    
    ### 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,
          home: Scaffold(
            body: Center(
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  const Spacer(),
                  const Text('enabled: true,\nrequestFocusOnTap: true,'),
                  const SizedBox(height: 16),
                  DropdownMenu<String>(
                    enabled: true,
                    initialSelection: 'First',
                    requestFocusOnTap: true,
                    width: 200,
                    dropdownMenuEntries: ['First', 'Second', 'Third']
                        .map((e) => DropdownMenuEntry(value: e, label: e))
                        .toList(),
                  ),
                  const Text('Expected: text cursor'),
                  const Spacer(),
                  const Text('enabled: true,\nrequestFocusOnTap: false,'),
                  const SizedBox(height: 16),
                  DropdownMenu<String>(
                    enabled: true,
                    initialSelection: 'First',
                    requestFocusOnTap: false,
                    width: 200,
                    dropdownMenuEntries: ['First', 'Second', 'Third']
                        .map((e) => DropdownMenuEntry(value: e, label: e))
                        .toList(),
                    // label: const Text('requestFocusOnTap: false'),
                  ),
                  const Text('Expected: clickable cursor'),
                  const Spacer(),
                  const Text('enabled: false,\nrequestFocusOnTap: true,'),
                  const SizedBox(height: 16),
                  DropdownMenu<String>(
                    enabled: false,
                    initialSelection: 'First',
                    requestFocusOnTap: true,
                    width: 200,
                    dropdownMenuEntries: ['First', 'Second', 'Third']
                        .map((e) => DropdownMenuEntry(value: e, label: e))
                        .toList(),
                  ),
                  const Text('Expected: deferred cursor'),
                  const Spacer(),
                  const Text('enabled: false,\nrequestFocusOnTap: false,'),
                  const SizedBox(height: 16),
                  DropdownMenu<String>(
                    enabled: false,
                    initialSelection: 'First',
                    requestFocusOnTap: false,
                    width: 200,
                    dropdownMenuEntries: ['First', 'Second', 'Third']
                        .map((e) => DropdownMenuEntry(value: e, label: e))
                        .toList(),
                  ),
                  const Text('Expected: deferred cursor'),
                  const Spacer(),
                ],
              ),
            ),
          ),
        );
      }
    }
    ```
    
    </details>
    
    ### Preview
    ![Screenshot 2024-03-25 at 14 52 31](https://github.com/flutter/flutter/assets/48603081/cf4361a5-d3bb-4635-9825-5eefa4efe6cc)
    d2c85529
Name
Last commit
Last update
..
animation Loading commit data...
cupertino Loading commit data...
foundation Loading commit data...
gestures Loading commit data...
material Loading commit data...
painting Loading commit data...
physics Loading commit data...
rendering Loading commit data...
scheduler Loading commit data...
semantics Loading commit data...
services Loading commit data...
widgets Loading commit data...
dart_plugin_registrant.dart Loading commit data...
web.dart Loading commit data...