I am trying to build Multiple DropdownButton using ListView.builder as many time as user clicks on the float action button
new FloatingActionButton(
onPressed: () {
setState(() {
counter++;
});
},
child: new Icon(Icons.add),
)
new ListView.builder(
itemBuilder: (BuildContext context, int index) {
return buildfields(index); },
itemCount: counter,
scrollDirection: Axis.vertical,
)
new DropdownButton<String>(
onChanged: (String value) { setState((){
setUn();
_unit = value;
});
},
hint: new Text('Course Unit'),
value: _unit,
items: <String>["1", "2", "3", "4", "5"].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
)
The problem am having is this, when user generates multiple DropdownButton and select the value for One, EVERY OTHER GENERATED DropdownButton CHANGES its Value to the newly selected value. How do i set a unique id for each generated DropdownButton?