【发布时间】:2021-11-19 06:17:12
【问题描述】:
当用户从dropdown 中选择Other 时,我正在尝试显示一个对话框,正在显示对话框但也会出现此错误。
错误:
type 'Future<bool?>' is not a subtype of type 'Widget'
代码:
这是我的对话代码
showAlertWithSingleTextField(
context, desc, title, labelText, controller, btnText, onPressButton) {
return Alert(
context: context,
title: title,
desc: desc,
content: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: labelText,
),
controller: controller,
),
],
),
buttons: [
DialogButton(
onPressed: onPressButton,
child: Text(btnText,
style: TextStyle(
fontFamily: 'montserrat', color: Colors.white, fontSize: 18)),
),
]).show();
}
这里是下拉代码
bool _newCatgoryFlag = false;
//here i'm calling dialogue box on the basis of condtion
addcatgerorytextfield(context) {
if (_newCatgoryFlag == true) {
SizedBox10();
print("run if");
return showAlertWithSingleTextField(
context,
"Please write your business category here",
"Add Category",
"Add Category",
newCategory,
"Add Category",
() {});
}
else {
return Padding(
padding: const EdgeInsets.only(left: 70),
child:
Row(crossAxisAlignment: CrossAxisAlignment.center, children: []));
}}
Widget build(BuildContext context) {
final color = HexColor("#7367f0");
return SafeArea(
child: Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(children: [
dropdownCustom(
context,
"Category",
_selectedCategory,
(newValue) {
setState(() {
this._selectedCategory = newValue.toString();
if (this._selectedCategory == "Other") {
_newCatgoryFlag = true;
} else {
_newCatgoryFlag = false;
}
});
},
categorylist.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value,
style: GoogleFonts.montserrat(
color: HexColor("#6e6b7b"),
)));
}).toList(),
MediaQuery.of(context).size.width * 0.9,
MediaQuery.of(context).size.width * 0.9,
),
SizedBox10(),
addcatgerorytextfield(context),
}
请帮忙解决一下。
【问题讨论】: