title: Flutter DropDownButton - How to display the selected value when dropdown button gets disabled?
body: <p>The Flutter DropdownButton shows some strange behaviour: it displays widget <code>disabledHint</code> instead of the selected value when it gets disabled (which must be done by setting <code>onChanged</code> to null).</p>
  
  <p>How can I display the selected value?</p>
  
  <p>Here is my sample code:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'DropdownButton disable problem',
        home: MyHomePage(),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    bool _enabled = true;
    int value;
    List&lt;DropdownMenuItem&lt;int&gt;&gt; items = [
      DropdownMenuItem(
        value: 11,
        child: Text('asdf'),
      ),
      DropdownMenuItem(
        value: 27,
        child: Text('qwert'),
      ),
      DropdownMenuItem(
        value: 31,
        child: Text('yxcv'),
      )
    ];
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text('DropdownButton problem'),
        ),
        body: Center(
          child: Column(
            children: &lt;Widget&gt;[
              Text(
                'Disabling the DropdownButton looses its selection',
              ),
              Switch(
                onChanged: (v) =&gt; setState(() {
                  _enabled = v;
                }),
                value: _enabled,
              ),
              DropdownButton(
                items: items,
                onChanged: _enabled
                    ? (v) =&gt; setState(() {
                          value = v;
                        })
                    : null,
                value: value,
              )
            ],
          ),
        ),
      );
    }
  }
  </code></pre>