How to implement drop down list in flutter? : <p>I have a list of locations that i want to implement as a dropdown list in Flutter. Im pretty new to the language. Here's what i have done.</p>

<pre><code>new DropdownButton(
  value: _selectedLocation,
  onChanged: (String newValue) {
    setState(() {
      _selectedLocation = newValue;
     });
},
items: _locations.map((String location) {
  return new DropdownMenuItem&lt;String&gt;(
     child: new Text(location),
  );
}).toList(),
</code></pre>

<p>This is my list of items:</p>

<pre><code>List&lt;String&gt; _locations = ['A', 'B', 'C', 'D'];
</code></pre>

<p>And I am getting the following error.</p>

<pre><code>Another exception was thrown: 'package:flutter/src/material/dropdown.dart': Failed assertion: line 468 pos 15: 'value == null || items.where((DropdownMenuItem&lt;T&gt; item) =&gt; item.value == value).length == 1': is not true.
</code></pre>

<p>I assume the value of <code>_selectedLocation</code> is getting null. But i am initialising it like so.</p>

<p><code>String _selectedLocation = 'Please choose a location';</code></p>
