FavoriteLoadingAdd to favorites

Requirements :
API Service
Object Model
Developer Recommendation : NB!!! – Use QuickType for your model.
(You need an already working api with a JSON response for quicktype) https://app.quicktype.io/
DropDownMenuItem
NB!!! – The DropDownMenuItem must be wrapped in a form widget to implement validation.

HINT : Avoid casting variable types such as <String> or <List> or <Object> until your list is actually working. In the DropdownButtonFormField Snippet, you will see no types are declared.

Step 1 :
Configuration :
(On your page.dart or screen.dart)

You need to include these.
1 : Your Model from QuickType

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Model
import './model/support_fields_model.dart';
// API
import 'package:project_name/api/support_fields_service.dart';
// Includes
import 'package:flutter/material.dart';
// Model import './model/support_fields_model.dart'; // API import 'package:project_name/api/support_fields_service.dart'; // Includes import 'package:flutter/material.dart';
// Model
import './model/support_fields_model.dart';
// API
import 'package:project_name/api/support_fields_service.dart';
// Includes
import 'package:flutter/material.dart';

DropdownButtonFormField Snippet :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
child: Form(
key: globalFormKey,
Container(
child: DropdownButtonFormField(
hint: Text("-- Select Query --"),
value: querySelect,
validator: (querySelect) =>
querySelect ==
"-- Select Query --"
? 'Select Query Required'
: null,
onChanged: (newValue) {
setState(() {
dropDownButtonCallback(
newValue, "select_query");
});
},
items: querySelectOptions
.map<DropdownMenuItem>((map) {
return DropdownMenuItem(
value: map.name,
child: Text(map.name),
);
}).toList(),
), // DropdownButtonFormField
), // Container
), // Form
child: Form( key: globalFormKey, Container( child: DropdownButtonFormField( hint: Text("-- Select Query --"), value: querySelect, validator: (querySelect) => querySelect == "-- Select Query --" ? 'Select Query Required' : null, onChanged: (newValue) { setState(() { dropDownButtonCallback( newValue, "select_query"); }); }, items: querySelectOptions .map<DropdownMenuItem>((map) { return DropdownMenuItem( value: map.name, child: Text(map.name), ); }).toList(), ), // DropdownButtonFormField ), // Container ), // Form
child: Form(
  key: globalFormKey,
    Container(
      child: DropdownButtonFormField(
        hint: Text("-- Select Query --"),
        value: querySelect,
        validator: (querySelect) =>
            querySelect ==
                    "-- Select Query --"
                ? 'Select Query Required'
                : null,
        onChanged: (newValue) {
          setState(() {
            dropDownButtonCallback(
                newValue, "select_query");
          });
        },
        items: querySelectOptions
            .map<DropdownMenuItem>((map) {
          return DropdownMenuItem(
            value: map.name,
            child: Text(map.name),
          );
        }).toList(),
      ), // DropdownButtonFormField
    ), // Container
  ), // Form

Pin It on Pinterest

Garth Baker
Favorite
Loading
en
af
sq
am
ar
hy
az
eu
be
bn
bs
bg
ca
ceb
ny
zh-CN
zh-TW
co
hr
cs
da
nl
en
eo
et
tl
fi
fr
fy
gl
ka
de
el
gu
ht
ha
haw
iw
hi
hmn
hu
is
ig
id
ga
it
ja
jw
kn
kk
km
ko
ku
ky
lo
la
lv
lt
lb
mk
mg
ms
ml
mt
mi
mr
mn
my
ne
no
ps
fa
pl
pt
pa
ro
ru
sm
gd
sr
st
sn
sd
si
sk
sl
so
es
su
sw
sv
tg
ta
te
th
tr
uk
ur
uz
vi
cy
xh
yi
yo
zu
Share This