#flutter #drop-down-menu
#трепетание #выпадающее меню
Вопрос:
[]1] вот мой код для .. у меня есть два текстовых файла для выбора даты и месяца рождения ….! и пользователь существует, тогда значение будет автоматически отображаться в текстовом файле! и пользователь может добавить новое выбранное значение из выпадающего списка ….! в моем случае я могу выбирать элементы из выпадающего списка, но не могу отображать выбранные элементы / значения на tetxfield, которые он удаляет, а текстовый файл отображается пустым! пожалуйста, помогите мне в этом……
String _Dob;
String _Anniversary;
Future<UserUpdate> _futureDateeupdate;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
var month = [
"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUEST", "SEPTEMBER", "OCTOBER",
"NOVEMBER", "DECEMBER"];
var date = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31];
@override
void initState() {
super.initState();
_futureDateeupdate = DateUpadte();
}
void nextField({String value, FocusNode focusNode}) {
if (value.isNotEmpty) {
focusNode.requestFocus();
}
}
FocusNode Anniversary;
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomPadding: false,
resizeToAvoidBottomInset: false,
body: (_isLoading)
? Center(child: CircularProgressIndicator())
: FutureBuilder<UserUpdate>(
future: _futureDateeupdate,
// ignore: missing_return
builder: (context, snapshot) {
if (snapshot.hasData) {
TextEditingController _textEditingControllerDOBb = TextEditingController(
text: snapshot.data.birthDate);
TextEditingController _textEditingControllerDate = TextEditingController(
text: snapshot.data.birthMonth);
TextEditingController _textEditingControllerAnniversaryy = TextEditingController(
text: snapshot.data.anniversaryDate);
return Form(
key: _formKey,
child: Stack(
children: <Widget>[
Positioned(
top: 330,
left: 30,
right: 30,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(
height: 70,
width: MediaQuery
.of(context)
.size
.width / 2.6,
child: TextFormField(
textInputAction: TextInputAction.next,
onTap: () {
FocusScope.of(context).requestFocus(
new FocusNode());
},
onFieldSubmitted: (value) {
nextField(
value: value, focusNode: Anniversary);
},
keyboardType: TextInputType.datetime,
controller: _textEditingControllerDOBb,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(
5.0),
borderSide: BorderSide(
color: const Color(0x3df58634)
)
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(
5.0)
),
labelText: 'Date Of Birth',
labelStyle: GoogleFonts.nunito(
color: const Color(0xfff58634)),
hintText: "Date Of Birth",
hintStyle: GoogleFonts.nunito(
color: const Color(0xfff58634)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(
5.0),
borderSide: BorderSide(
color: const Color(0x3df58634),
)
),
suffixIcon: PopupMenuButton<String>(
icon: const Icon(Icons.arrow_drop_down),
onSelected: (String value) {
_textEditingControllerDOBb.text = value;
},
itemBuilder: (BuildContext context) {
return month
.map<PopupMenuItem<String>>((
String value) {
return new PopupMenuItem(
child: new Text(value),
value: value);
}).toList();
},
),
),
validator: (String value) {
if (value.isEmpty) {
return 'DOB is Missing';
}
return null;
},
onSaved: (String value) {
_Dob = value;
},
),
),
SizedBox(
height: 70,
width: MediaQuery
.of(context)
.size
.width / 2.6,
child: TextFormField(
onTap: () {
FocusScope.of(context).requestFocus(
new FocusNode());
},
onFieldSubmitted: (value) {
nextField(
value: value, focusNode: Anniversary);
},
controller: _textEditingControllerDate,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(
5.0),
borderSide: BorderSide(
color: const Color(0x3df58634)
)
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(
5.0)
),
labelText: 'Date Of Birth',
labelStyle: GoogleFonts.nunito(
color: const Color(0xfff58634)),
hintText: "Date Of Birth",
hintStyle: GoogleFonts.nunito(
color: const Color(0xfff58634)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(
5.0),
borderSide: BorderSide(
color: const Color(0x3df58634),
)
),
suffixIcon: PopupMenuButton<int>(
icon: const Icon(Icons.arrow_drop_down),
onSelected: (int value) {
_textEditingControllerDate.text =
"$value";
},
itemBuilder: (BuildContext context) {
return date
.map<PopupMenuItem<int>>((
int value) {
return new PopupMenuItem(
child: new Text("$value"),
value: value);
}).toList();
},
),
),
validator: (String value) {
if (value.isEmpty) {
return 'DOB is Missing';
}
return null;
},
onSaved: (String value) {
_Dob = value;
},
),
),
]
)
),
Комментарии:
1. Не могли бы вы включить изображение / эскиз дизайна, который вы имеете в виду или которому следуете? Это поможет лучше понять проблему.
2. да, я загрузил свое изображение, пожалуйста, проверьте