当我按下按钮来验证FormKey时,TextFormField的错误边框没有激活。 我想按一下按钮,如果未通过验证,则显示红色边框。
OnPress按钮:
if(this._formKeyEmail.currentState.validate()){
//Pass
}
TextFormField:
Container(
width: this.widget.width,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.0),
boxShadow: ThemeEffect.shadowInputField()
),
child: TextFormField(
onChanged: this.widget.onChanged,
maxLength: this.widget.maxLength,
textAlign: TextAlign.center,
keyboardType: this.widget.textInputType,
controller: this.widget.controller,
validator: this.widget.validator,
style: ThemeText.sign_up_input_field,
decoration: InputDecoration(
counter: SizedBox.shrink(),
errorBorder:OutlineInputBorder(
borderSide: BorderSide(
color: ThemeColor.flamingo,
width: 1
),
),
errorStyle: TextStyle(height: 0),
hintText: this.widget.hintText,
hintStyle: ThemeText.sign_up_input_field_hint,
border: new OutlineInputBorder(
borderRadius: BorderRadius.circular(6.0),
borderSide: BorderSide.none,
),
filled: true,
fillColor: ThemeColor.white
),
),
)
验证者:
validator: (String value){
if (!Validator.email(value)){
return "error";
}
return null;
}
显示“错误”标签,但不显示边框Color.Flaming。
答案 0 :(得分:0)
您是否尝试过errorBorder属性? 示例:
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(6.0),
borderSide: BorderSide.none,
),