【发布时间】:2021-04-14 12:40:09
【问题描述】:
我尝试从我的 Flutter 应用程序中收集 Firestore 中的数据。使用以下代码:我的问题是当用户没有在 DropdownMenuItem 上选择项目时如何显示错误消息?
body: Form(
key: _formKeyValue,
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 12.0),
children: <Widget>[
SizedBox(height: 20.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
DropdownButton(
items: _specialite
.map((value) => DropdownMenuItem(
child: Text(
value,
textAlign: TextAlign.center,
style: TextStyle(color: Colors.black),
),
value: value,
))
.toList(),
onChanged: (selectedAccountType) {
print('$selectedAccountType');
setState(() {
medicalType = selectedAccountType;
});
},
value: medicalType,
isExpanded: false,
hint: Text(
'choisissez la spécialité',
style: TextStyle(color: Colors.black),
),
)
],
),
....
....
我使用了这个答案https://stackoverflow.com/a/59746301/15400156,但屏幕上没有显示任何内容。
【问题讨论】:
标签: android firebase flutter dart