Как показать мой виджет только тогда, когда в моем раскрывающемся меню выбрана одна из опций?
Я пробую это:
showWidgetOnCategory() async {
if(_selectedCategory == 'FREE'){
_buildCountPerson();
}
}
Widget _dropdownCategory(){
return Padding(
padding: EdgeInsets.only(left:0),
child: DropdownButton(
isExpanded: true,
hint: Text('Type', style: TextStyle(color: Colors.grey.shade300),),
value: _selectedCategory,
onChanged: (newValue){
setState(() async {
_selectedCategory = newValue;
});
},
items: _categories.map((category){
return DropdownMenuItem(
child: new Text(category, style: TextStyle(color: Colors.black),),
value: category,
);
}).toList(),
)
);
}
_buildCountPerson(){
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return Container(
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(right: 15),
child: Text('Liczba miejsc:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
)),
SizedBox(
width: 120,
height: 50,
child: TextFormField(
keyboardType: TextInputType.number,
controller: _countPersonOnEventController,
decoration: InputDecoration(
hintText: '0',
border: new OutlineInputBorder(
borderSide: new BorderSide(color: Colors.teal)
),
),
validator: (String value) {
if(value.isEmpty){
return 'Pole wymagane';
}else return null;
},
onSaved: (String value) {
_count = int.parse(value);
print(_count);
},
)
)
],
));
}
, но это не работает, кто-нибудь знает, как помочь мне?
//////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////////