title: Set default value for dropdown button in flutter
body: <p>I have a dropdown button which works fine, but when I try to set a default value it will fail with the following error: </p>
  
  <blockquote>
    <p>'package:flutter/src/material/dropdown.dart': Failed assertion: line 620 pos 15: 'items == null || items.isEmpty || value == null || items.where((DropdownMenuItem item) => item.value == value).length == 1': is not true.</p>
  </blockquote>
  
  <p>This is my dropdown button: </p>
  
  <pre><code> Widget changeWorkspace() {
  return StatefulBuilder(
      builder: (BuildContext context, StateSetter setState) {
    return Column(mainAxisSize: MainAxisSize.min, children: &lt;Widget&gt;[
      Padding(
        padding: EdgeInsets.all(8.0),
        child: DropdownButton&lt;AssignedWorkspace&gt;(
            isExpanded: true,
            hint: Text("SELECT WORKSPACE"),
            value: selectedWorkspace,
            onChanged: (dropdownValueSelected) {
              setState(() {
                selectedWorkspace = dropdownValueSelected;
              });
            },
            items: workspaces != null &amp;&amp; workspaces.length &gt; 0
                ? workspaces.map((AssignedWorkspace workspace) {
                    return new DropdownMenuItem&lt;AssignedWorkspace&gt;(
                      value: workspace,
                      child: new Text(workspace.name,
                          style: new TextStyle(color: Colors.black)),
                    );
                  }).toList()
                : null),
      ),
    ]);
  });
  </code></pre>
  
  <p>}</p>
  
  <p>I've tried to set the value of selectedWorkspace onInit as follows but it fails. </p>
  
  <pre><code>selectedWorkspace = new AssignedWorkspace(
  id: userSettings.currentWorkspaceId,
  name: userSettings.currentWorkspaceName);
  </code></pre>
  
  <p>Is there a way of setting a default value in a dropdown button? </p>