简体   繁体   English

在 Flutter 中,如何更改 TextFormField 验证错误行样式?

[英]In Flutter, How can I change TextFormField validation error line style?

I want to set a different color for the error line created by the validator in TextFormField but I don't know how...我想为 TextFormField 中的验证器创建的错误行设置不同的颜色,但我不知道如何...

Change the color and the width to your likings providing errorBorder and focusedErrorBorder inside InputDecoration as decoration for TextFormField :根据您的喜好更改颜色宽度,在InputDecoration中提供errorBorderfocusedErrorBorder作为TextFormField的装饰:

TextFormField(
        decoration: InputDecoration(
          focusedErrorBorder:UnderlineInputBorder(
            borderSide: const BorderSide(color: Colors.blue, width: 2.0))
          errorBorder: UnderlineInputBorder(
            borderSide: const BorderSide(color: Colors.blue, width: 2.0),
          ),
        ),
      ),

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter Textformfield 验证器将最后一个 TextFormfield 集中在验证错误上,而不是第一个 - Flutter Textformfield validator Focuses Last TextFormfield on validation error instead of first 如何更改 TextFormField() 小部件颜色 Flutter - How to change TextFormField() widget color Flutter Flutter:向 Column 添加了一个额外的 TextFormField 但显示没有变化 - Flutter: Added an additional TextFormField to Column but no change in display 如何使用 Controller 在我的 TextFormField 上设置初始值? - How can I put an initial value on my TextFormField with a Controller? 如何在 Flutter 中对齐 TextFormField 旁边的文本? - How to align Text next to TextFormField in Flutter? 我可以更改HTML5表单验证检查的错误弹出窗口吗 - Can I change error popups for HTML5 form validation checks 当我将输入值强制输入到 flutter 中的该字段时,如何避免滚动到 TEXTFORMFIELD - how to avoid scrolling to the TEXTFORMFIELD when I force input value to that field in flutter Flutter 表单同时显示所有字段的错误。 如何让它显示一个字段的验证消息? - Flutter form is showing error for all the fields all at once. How can I make it to show the validation message of one field after the other? Flutter 中不推荐使用 TextFormField 的自动验证 - Autovalidate of TextFormField is deprecated in Flutter 仅当专注于颤动时如何在 TextFormField() 上显示计数器文本? - How to display counter text on TextFormField() only when focused in flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM