Прежде всего, я знаю, что на самом деле это невозможно, но у меня есть проблема, и я не знаю, что делать. Я хочу использовать DropDown, но он не изменит текст без setState, и я не могу преобразовать этот код в StatefulWidget. Что мне делать? Код не имеет большого значения, но вот он (не весь код):
Widget buildAboutDialog(
BuildContext context, _myHomePageState, bool isEdit, Clothes clothes){
if(clothes != null){
this.clothes = clothes;
teCategoryName = clothes.category;
teBrandName.text = clothes.brand;
teColorName.text = clothes.color;
teSizeName.text = clothes.size;
teQtyName.text = clothes.qty;
}
return new AlertDialog(
title: new Text(isEdit ? 'Edit' : 'Add new Clothes'),
content: new SingleChildScrollView(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Center(
child: DropdownButton(
hint: Text("Choose Category"),
value: teCategoryName,
isExpanded: true,
onChanged: (newValue){
teCategoryName = newValue;
**setState(() {
teCategoryName = newValue;
});**
},
items: _categorynames.map((location){
return DropdownMenuItem(
child: new Text(location),
value: location,
);
}).toList(),
),
),
),