Я использовал здесь библиотеку flutter_form_builder. Я использовал три поля формы. Раскрывающееся поле не передает значение кнопке отправки. Два других поля передают значение. Я не могу найти проблему здесь.
Здесь я делюсь своим полным исходным кодом, используя pastebin .
Также вы проверяете мой код FormBuilderCustomField ниже
FormBuilderCustomField(
attribute: "category",
formField: FormField(
enabled: true,
builder: (FormFieldState<dynamic> field) {
return InputDecorator(
decoration: InputDecoration(
labelText: "Select Event Category",
labelStyle: TextStyle(
color: Color(0xffF9B538),
fontSize: 18
),
contentPadding:
EdgeInsets.all(8.0),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(5.0)),
borderSide: BorderSide(color: Color(0xffF9B538))
),
errorText: field.errorText,
),
child: FutureBuilder<List<Categories>>(
future: _fetchCats(),
builder: (BuildContext context, AsyncSnapshot<List<Categories>> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
} else if (snapshot.hasError) {
return Center(
child: Text(snapshot.error),
);
} else {
return DropdownButton<String>(
isExpanded: true,
items: snapshot.data?.map((Categories value) {
return new DropdownMenuItem<String>(
value: value.name,
child: new Text(value.name, style: new TextStyle(fontSize: 16.0),),
);
})?.toList() ?? [],
onChanged: (String value) {
setState(() {
print(value);
_currentItemSelected = value;
field.didChange(value);
});
},
value: _currentItemSelected == ""
? _currentItemSelected = snapshot.data.first.name
: _currentItemSelected,
hint: Text('Event Category',
style: TextStyle(
fontSize: 15,
color: Colors.black,
),
),
underline: Container(
decoration: const BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))
),
),
style: TextStyle(
fontSize: 15,
color: Color(0xffF9B538),
),
);
}
}
) //FutureBuilder
);
},
),
), //customFormBuilder