【发布时间】:2022-01-21 20:58:37
【问题描述】:
我遇到了这个错误,我不知道是什么原因解决它。
class PasswordTextFormField extends StatelessWidget {
final Function validator;
final String name;
PasswordTextFormField({required this.name, required this.validator});
@override
Widget build(BuildContext context) {
return TextFormField(
validator: validator, // here it gives the error
decoration: InputDecoration(
border: const OutlineInputBorder(),
hintText: name,
),
);
}
}
它给出了这种错误:
参数类型“函数”不能分配给参数类型 '细绳?函数(字符串?)?'。
如果你没听懂我说的话:
感谢您的帮助!
【问题讨论】:
-
添加一个带参数的匿名函数
-
请分享您的代码,您的验证器函数返回类型与验证器的预期返回类型不匹配
-
Mr.Faizan 请问在哪里可以联系InTouch?
-
先生。 Zabaykal 我怎么不明白