pbs_mhl
pbs_mhl

Reputation: 77

Is there a way to fetch DropDownButtonFormField items from database only when user taps (clicks on web) on button to open it?

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

Answers (0)

Related Questions