title: OnTap Function in the DropDownMenu Button in Flutter
body: <p>I've tried to populate the dropdown menu button with the data from the SQLite database.
  Then on the onTap Function I wanted to navigate to the selected category.</p>
  <p>When I tap on the category it does not navigate.</p>
  <p>I have saved each category with an id in the database which is used the identify the selected item.
  Here is the code:</p>
  <p>'''</p>
  <pre><code>class _HomeState extends State&lt;Home&gt; {
  
    TodoService _todoService;
    var _selectedValue;
  
    var _categories = List&lt;DropdownMenuItem&gt;();
  
    List&lt;Todo&gt;_todoList=List&lt;Todo&gt;();
  
  @override
    initState(){
      super.initState();
  _loadCategories();
  
    }
  
  _loadCategories() async {
      var _categoryService = CategoryService();
      var categories = await _categoryService.readCategory();
      categories.forEach((category) {
        setState(() {
          _categories.add(DropdownMenuItem(
            child: Text(category['name']),
            value: category['name'],
            onTap: ()=&gt;Navigator.of(context).push(MaterialPageRoute(builder:(context)=&gt;TodosByCategory(category: category['name'],))),
          ));
        });
      });
    }
  
  @override
    Widget build(BuildContext context) {
      return Scaffold(
        key: _globalKey,
        appBar: AppBar(
          actions: &lt;Widget&gt;[
            DropdownButtonHideUnderline(
              child: DropdownButton(
                value: _selectedValue,
                items: _categories,
                dropdownColor: Colors.blue,
                style: TextStyle(color: Colors.white,fontSize: 16.0),
                iconDisabledColor: Colors.white,
                iconEnabledColor: Colors.white,
                onChanged: (value) {
                  setState(() {
                    _selectedValue = value;
                  });
                },
              ),
            ),
  </code></pre>
  <p>'''</p>
  <p>Here is the todosByCategory():</p>
  <p>'''</p>
  <pre><code>class _TodosByCategoryState extends State&lt;TodosByCategory&gt; {
  
    List&lt;Todo&gt;_todoList=List&lt;Todo&gt;();
  
    TodoService _todoService=TodoService();
  
    @override
    initState(){
      super.initState();
      getTodosByCategories();
    }
  
    getTodosByCategories()async{
      var todos=await _todoService.readTodoByCategory(this.widget.category);
      todos.forEach((todo){
        setState(() {
          var model= Todo();
          model.title=todo['title'];
          model.dueDate=todo['dueDate'];
  
          _todoList.add(model);
  
        });
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text('Todos By Category'),
        ),
        body: Column(
          children: &lt;Widget&gt;[
            Expanded(
              child: ListView.builder(
                itemCount: _todoList.length,
                itemBuilder: (context, index){
                return Padding(
                  padding: EdgeInsets.only(top:8.0, left: 8.0, right: 8.0),
                  child: Card(
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(0),
                    ),
                    elevation: 8.0,
                    child: ListTile(
                      title: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: &lt;Widget&gt;[
                          Text(_todoList[index].title)
                        ],
                      ),
                      subtitle: Text(_todoList[index].dueDate),
  //                    trailing: Text(_todoList[index].dueDate),
                    ),
                  ),
                );
              },),
            )
          ],
        ),
      );
    }
  }
  </code></pre>
  <p>'''
  Please help me out.</p>