How can I remove the error message in TextFormField
created by validator? I just want the red border because I don't have the space to show the error.
bool error = false;
TextFormField (
hintText:error?'please input productName':'',
hintStyle:TextStyle(color: Colors.red),
validator:(v){
v.trim().length>0?error=false:error=true; return null;
}
)
You can return an empty string which will still mark the borders red if not valid
validator: (String value) {
if (value.isEmpty) {
return '';
}
},
What I did to fix that was wrap the TextField with SizedBox and give a fixed height then want expand with error message
SizedBox(
height: SOME_FIXED_HEIGHT_INCLUDING_ERROR_MESSAGE'S_HEIGHT,
child: TextField()