[FLUTTER]:如何在TextField中输入depecoration中启用/禁用errortext属性?
当表单的输入不尊重允许字符时,我需要激活错误消息。 我该怎么做?
我尝试了 errortext ,但是如果它处于活动状态,则即使输入正确,该错误仍然存在。 我需要仅在表单为空的时出现错误消息,并且当字符输入不匹配时。
child: TextField(
controller: state.registrySizeTxtEditCtrl,
decoration: InputDecoration(
errorText: errText,
enabled: state.revocation,
labelText: 'Registry Size',
hintText: '0 - 1000',
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(7.0),
),
),
keyboardType: TextInputType.none,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(
RegExp(r'^([0-9][0-9]{0,2}|1000)$')),
],),
I need to activate an error message when the input of the form does not respect the allowed characters.
How can I do that?
I tried errortext, but if it is active, the error remains even when the input is right.
I need the error message to appear only when the form is empty and when the characters entered do not match the format.
child: TextField(
controller: state.registrySizeTxtEditCtrl,
decoration: InputDecoration(
errorText: errText,
enabled: state.revocation,
labelText: 'Registry Size',
hintText: '0 - 1000',
border: OutlineInputBorder(
borderRadius:
BorderRadius.circular(7.0),
),
),
keyboardType: TextInputType.none,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(
RegExp(r'^([0-9][0-9]{0,2}|1000)
)),
],),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论