title: Error when selecting a dropdown item in Flutter
body: <p>I have a problem with a Flutter dropdown. When I select one of the items it throws an error:</p>
  
  <blockquote>
    <p>Another exception was thrown: 'package:flutter/src/material/dropdown.dart': Failed assertion: line 481 pos 15: 'value == null || items.where((DropdownMenuItem item) => item.value == value).length == 1': is not true.</p>
  </blockquote>
  
  <p>I was searching and people tell that this error is produced because the selected element doesn't belong to the original list but after some debug  I can see it does. I can't find the source of this error, so I would appreciate any help.</p>
  
  <p>Here is my code</p>
  
  <p>FeedCategory model</p>
  
  <pre><code>import 'package:meta/meta.dart';
  
  class FeedCategory {
    static final dbId = "id";
    static final dbName = "name";
  
    int id;
    String name;
  
    FeedCategory({this.id, @required this.name});
  
    FeedCategory.fromMap(Map&lt;String, dynamic&gt; map)
        : this(
      id: map[dbId],
      name: map[dbName],
    );
  
    Map&lt;String, dynamic&gt; toMap() {
      return {
        dbId: id,
        dbName: name,
      };
    }
  
    @override
    String toString() {
      return 'FeedCategory{id: $id, name: $name}';
    }
  }
  </code></pre>
  
  <p>Widget</p>
  
  <pre><code>import 'package:app2date/repository/repository.dart';
  import 'package:app2date/model/FeedSource.dart';
  import 'package:app2date/model/FeedCategory.dart';
  import 'package:app2date/util/ui.dart';
  import 'package:flutter/material.dart';
  
  class ManageFeedSource extends StatefulWidget {
    ManageFeedSource({Key key, this.feedSource}) : super(key: key);
  
    final FeedSource feedSource;
  
    @override
    _ManageFeedSource createState() =&gt; new _ManageFeedSource();
  }
  
  class _ManageFeedSource extends State&lt;ManageFeedSource&gt; {
    FeedCategory _feedCategory;
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text('New Feed'),
        ),
        body: new FutureBuilder(
          future: Repository.get().getFeedCategories(),
          builder: (BuildContext context, AsyncSnapshot snapshot) {
            List&lt;FeedCategory&gt; categoriesList = snapshot.data;
            if (categoriesList != null) {
              return new DropdownButton&lt;FeedCategory&gt;(
                hint: Text('Choose category...'),
                value: _feedCategory,
                items: categoriesList.map((FeedCategory category) {
                  return DropdownMenuItem&lt;FeedCategory&gt;(
                    value: category,
                    child: Text(category.name),
                  );
                }).toList(),
                onChanged: (FeedCategory category) {
                  print('Selected: $category');
                  setState(() {
                    _feedCategory = category;
                  });
                },
              );
            } else {
              return Container(
                decoration: new BoxDecoration(color: Colors.white),
              );
            }
          },
        ),
      );
    }
  
    @override
    void initState() {
      super.initState();
    }
  }
  </code></pre>
  
  <p>Repository getFeedCategories method</p>
  
  <pre><code>Future&lt;List&lt;FeedCategory&gt;&gt; getFeedCategories() async {
    return await database.getFeedCategories();
  }
  </code></pre>
  
  <p>Database getFeedCategories method</p>
  
  <pre><code>Future&lt;List&lt;FeedCategory&gt;&gt; getFeedCategories() async {
    var dbClient = await db;
    var query = "SELECT * FROM $feedCategoryTableName;";
    var result = await dbClient.rawQuery(query);
    List&lt;FeedCategory&gt; feedCategories = [];
    for (Map&lt;String, dynamic&gt; item in result) {
      feedCategories.add(new FeedCategory.fromMap(item));
    }
    return feedCategories;
  }
  </code></pre>
  
  <p>The categoriesList content and the selected category (debugger)
  <a href="https://i.stack.imgur.com/IiWib.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IiWib.png" alt="enter image description here"></a></p>