title: how to filter json from dropdown in flutter
body: <p><code>enter code here</code>hey all of master , i have code for filter data on api json, i want my user can select specific teacher by specific locatioin on drop down. the search by name are already work, but the dropdown i don't know how to implement it, to take effect on my json api slection.</p>
  
  <p>here is my code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import 'package:flutter/material.dart';
  
  
  void main() {
    runApp(new MaterialApp(
      title: "Para Dai",
      home: new DropDown(),
    ));
  }
  
  class DropDown extends StatefulWidget {
    DropDown() : super();
  
  
  // end
    final String title = "DropDown Demo";
  
    @override
    DropDownState createState() =&gt; DropDownState();
  }
  
  class Province {
    int id;
    String name;
  
    Province(this.id, this.name);
  
    static List&lt;Province&gt; getProvinceList() {
      return &lt;Province&gt;[
        Province(1, 'Central Java'),
        Province(2, 'East kalimantan'),
        Province(3, 'East java'),
        Province(4, 'Bali'),
        Province(5, 'Borneo'),
      ];
    }
  }
  
  // ADD THIS
  class District {
    int id;
    String name;
  
    District(this.id, this.name);
  
    static List&lt;District&gt; getDistrictList() {
      return &lt;District&gt;[
        District(1, 'Demak'),
        District(2, 'Solo'),
        District(3, 'Sidoarjo'),
        District(4, 'Bandung'),
      ];
    }
  }
  
  class DropDownState extends State&lt;DropDown&gt; {
    String finalUrl = '';
  
    List&lt;Province&gt; _provinces = Province.getProvinceList();
    List&lt;DropdownMenuItem&lt;Province&gt;&gt; _dropdownMenuItems;
    Province _selectedProvince;
  
    // ADD THIS
    List&lt;District&gt; _disctricts = District.getDistrictList();
    List&lt;DropdownMenuItem&lt;District&gt;&gt; _dropdownMenuDistricts;
    District _selectedDistrict;
  
    @override
    void initState() {
      _dropdownMenuItems = buildDropdownMenuItems(_provinces);
      _dropdownMenuDistricts = buildDropdownDistricts(_disctricts); // Add this
      _selectedProvince = _dropdownMenuItems[0].value;
      _selectedDistrict = _dropdownMenuDistricts[0].value; // Add this
      super.initState();
    }
  
    List&lt;DropdownMenuItem&lt;Province&gt;&gt; buildDropdownMenuItems(List provinceses) {
      List&lt;DropdownMenuItem&lt;Province&gt;&gt; items = List();
      for (var province in provinceses) {
        items.add(
          DropdownMenuItem(
            value: province,
            child: Text(province.name),
          ),
        );
      }
      return items;
    }
  
    // ADD THIS
    List&lt;DropdownMenuItem&lt;District&gt;&gt; buildDropdownDistricts(
        List&lt;District&gt; districts) {
      List&lt;DropdownMenuItem&lt;District&gt;&gt; items = List();
      for (var district in districts) {
        items.add(
          DropdownMenuItem(
            value: district,
            child: Text(district.name),
          ),
        );
      }
      return items;
    }
  
    onChangeDropdownItem(Province newProvince) {
      // Add this
      final String url =
          'https://onobang.com/flutter/index.php?province=${newProvince.name}&amp;district=${_selectedDistrict.name}';
      setState(() {
        _selectedProvince = newProvince;
        finalUrl = url; // Add this
      });
    }
  
    onChangeDistrict(District newDistrict) {
      // Add this
      final String url =
          'https://onobang.com/flutter/index.php?province=${_selectedProvince.name}&amp;district=${newDistrict.name}';
      setState(() {
        _selectedDistrict = newDistrict;
        finalUrl = url; // Add this
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return new MaterialApp(
        debugShowCheckedModeBanner: false,
        home: new Scaffold(
          appBar: new AppBar(
            title: new Text("DropDown Button Example"),
          ),
          body: new Container(
            margin: const EdgeInsets.all(0.0),
            padding: const EdgeInsets.all(13.0),
            child: new Column(
              children: &lt;Widget&gt;[
                new Container(
                  margin: const EdgeInsets.all(0.0),
                  padding: const EdgeInsets.all(13.0),
                  decoration: new BoxDecoration(
                      border: new Border.all(color: Colors.blueGrey)),
                  child: new Text(
                      "Welcome to teacher list app, please select teacher by province / district and name"),
                ),
                new Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: &lt;Widget&gt;[
                    Text("Prov : "),
                    SizedBox(
                      height: 20.0,
                    ),
                    DropdownButton(
                      value: _selectedProvince,
                      items: _dropdownMenuItems,
                      onChanged: onChangeDropdownItem,
                    ),
                    SizedBox(
                      height: 20.0,
                    ),
                    // Text('Selected: ${_selectedProvince.name}'),
                    //  SizedBox(
                    //   height: 20.0,
                    // ),
  
                    Text(" Dist : "),
                    SizedBox(
                      height: 20.0,
                    ),
                    DropdownButton(
                      value: _selectedDistrict,
                      items: _dropdownMenuDistricts,
                      onChanged: onChangeDistrict,
                    ),
                    SizedBox(
                      height: 20.0,
                    ),
                    // Text('Selected: ${_selectedDistrict.name}'),
                    // SizedBox(
                    //   height: 20.0,
                    //  ),
                    // Padding(
                    // padding: const EdgeInsets.all(8.0),
                    // child: Text('$finalUrl'),
                    // ),
                  ],
                ),
                new Card(
                    child: new Center(
                        child: TextFormField(
                  decoration: InputDecoration(labelText: 'Teacher Name'),
                ))),
                new FlatButton(
                  color: Colors.blue,
                  textColor: Colors.white,
                  disabledColor: Colors.grey,
                  disabledTextColor: Colors.black,
                  padding: EdgeInsets.all(8.0),
                  splashColor: Colors.blueAccent,
                  onPressed: () {
                    Navigator.push(
                        context,
                        MaterialPageRoute(builder: (context) =&gt; SecondWidget(value:"$finalUrl"))
                    );
                    // what action to show next screen
                  },
                  child: Text(
                    "Show List",
                  ),
                ),
              ],
            ),
          ),
        ),
      );
    }
  }
  // ignore: must_be_immutable
  class SecondWidget extends StatelessWidget
  {
    String value;
  
  
    SecondWidget({Key key, @required this.value}):super(key:key);
  
    @override
    Widget build(BuildContext context) {
      // TODO: implement build
      return Scaffold(
          appBar: AppBar(title: Text("Page 2"),),
          body: Column(children: &lt;Widget&gt;[
            Text("I wish Show JSON Mysql listview with this URL : "+this.value),
            RaisedButton(child: Text("Go Back"),
                onPressed: () {
                  Navigator.pop(context);
                }),
          ],)
      );
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>any help very thanks before iam a beginner in flutter, and very dificult to learn flutter</p>