Reputation: 77
I have a DropDownButtonFormField in a Form as an optional field. Is there a way only to populate items of it if users clicks on the button or taps on it because it makes a network request. Progress indicator will be shown until it loads data.
Row(
children: [
Flexible(
child: DropdownButtonFormField<pdtModel.Layers>(
items: pdtModel.Layers.values
.map((pdtModel.Layers value) => DropdownMenuItem(
value: value, child: Text(value.displayName)))
.toList(),
onChanged: (pdtModel.Layers? value) {
selectedLayers = value;
},
decoration: Utils.textFormFieldStyle(
labelTextStr: 'Layers',
hintTextStr: 'Choose number of layers'
),
),
),
// .... More Widgets
]
)
Upvotes: 0
Views: 44