【发布时间】:2022-02-12 10:05:29
【问题描述】:
我是 Flutter 和 Dart 语言的新手,我正在努力自学。
所以,我的问题是我有一个 DropdownButtonFormField 有 2 个值(私人聊天和电话号码):
Widget menu(){
return DropdownButtonFormField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'how to contact with the buyer?',
labelStyle: TextStyle(
fontSize: 16,
color: Colors.grey,
fontFamily: 'Almarai'
),
),
items: <String>['phone number', 'private chat'].map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String newValue) {
setState(() {
dropdownvalue = newValue;
});
},
);
}
我有这个TextFormField,如果选择了(私人聊天)选项,我希望它隐藏:
Widget phonenum(){
return
TextFormField(
maxLength: 10,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'phone number',
labelStyle: TextStyle(
fontSize: 16,
color: Colors.grey,
fontFamily: 'Almarai'
),
),
);
}
请问我该如何实现?而且,如何使用 RadioButton 而不是 DropdownButtonFormField 来实现它?因为我还没有决定哪一个更适合我的项目流程。
【问题讨论】:
标签: flutter dart radio-button