When my flutter textformfield throws a validation error, the caret color changes to the same color that I have set in errorStyle.
Is there a way to turn this off?
TextFormField(
controller: emailController,
decoration: getInputDecorationTheme('Email'),
validator: (value) {
setState(
() {
errorMessage = '';
},
);
if (value == null || value.isEmpty) {
return 'Please enter your email';
}
if (!_isValidEmail(value)) {
return 'Please enter a valid email address';
}
return null;
},
),
And this is how my decoration looks.
InputDecoration getInputDecorationTheme(String hintText) {
return InputDecoration(
hintText: hintText,
hintStyle: const TextStyle(color: Colors.grey),
errorStyle: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w500,
),
filled: true,
fillColor: StaticColors.backgroundColor,
border: const OutlineInputBorder(borderSide: BorderSide.none),
// contentPadding: const EdgeInsets.symmetric(vertical: 15, horizontal: 15),
contentPadding: const EdgeInsets.only(bottom: 0.0, top: 15.0),
prefix: const Padding(
padding: EdgeInsets.only(left: 15.0),
),
);
}
Here is how the caret looks per default (I always want to show this color).

Here is how the caret looks when I've triggered a validation error.

Tried looking in the decorator to find a settings for this but doesn't seem to exist.
You can set the
cursorColor: Colors.blackto fix for all states of textformfield.