title: How to navigate to another screen from dropdownbutton in Flutter?
body: <p>I am trying to get a dropdownlist to navigate to another screen once one of the items in the list is pressed via the dropdownbutton. I have tried using Navigator.push straight into onChanged but that doesnt work. And i have tried creating a new button in set state in onChanged. How can I do this because I do not know how?</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  void main() =&gt; runApp(new HomeNavigator());
  
  class HomeNavigator extends StatefulWidget {
  @override
  _HomeNavigator createState() =&gt; _HomeNavigator();
  }
  
  class _HomeNavigator extends State&lt;HomeNavigator&gt; {
  List&lt;DropdownMenuItem&lt;String&gt;&gt; listMunicipalities = [];
  String selected = null;
  void loadData() {
  listMunicipalities = [];
  listMunicipalities.add(new DropdownMenuItem(
    child: new Text('Port Moody'),
    value: 'Port Moody',
  ));
  listMunicipalities.add(new DropdownMenuItem(
    child: new Text('Vancouver Downtown'),
    value: 'Vancouver Downtown',
  ));
  listMunicipalities.add(new DropdownMenuItem(
    child: new Text('Coquitlam'),
    value: 'Coquitlam',
  ));
  }
  
  @override
  Widget build(BuildContext context) {
  loadData();
  Color gradientStart = Colors.deepOrange[700];
  Color gradientEnd = Colors.purple[500];
  
  return new MaterialApp(
      home: new Scaffold(
          body: new Container(
              decoration: new BoxDecoration(
                gradient: new LinearGradient(
                    colors: [gradientEnd, gradientStart],
                    begin: new FractionalOffset(0.0, 0.5),
                    end: new FractionalOffset(0.5, 0.0),
                    stops: [0.0, 1.0]),
              ),
              child: Stack(children: [
                Container(
                    child: Text('',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                            fontSize: 30.0,
                            fontFamily: 'College-Block',
                            color: Colors.white.withOpacity(0.7))),
                    alignment: Alignment(0.0, -0.5)),
                Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: new Center(
                        child: new Container(
                      alignment: Alignment(0.0, 0.05),
                      child: Container(
                          width: 350.0,
                          child: DropdownButtonHideUnderline(
                            child: new DropdownButton(
                              value: selected,
                                items: listMunicipalities,
                                hint: Text(
                                  'Select City',
                                  textAlign: TextAlign.center,
                                  style: TextStyle(
                                      fontWeight: FontWeight.bold,
                                      color: Colors.white.withOpacity(0.5)),
                                ),
                                onChanged: (value){
  
                                }),
                          )),
                    )))
              ]))));
  }
  }
  
  
  class HomePage extends StatefulWidget{
  @override
  _HomePage createState() =&gt; _HomePage();
  }
  
  class _HomePage extends State&lt;HomePage&gt; {
  
  
  Widget build(BuildContext context){
  return Scaffold(
    appBar: AppBar(
      title: Text('')
    ),
   );  
  }
  }
  </code></pre>