setErrorMessage method
Sets a custom error message for a specific field.
The key
parameter is required and must be the key of an existing field.
The errorMessage
parameter is the custom error message to be set.
The isRedrawState
parameter determines whether to redraw the state after setting the error message.
Implementation
void setErrorMessage(
String key,
String? errorMessage, {
bool isRedrawState = true,
}) {
_checkIfKeyExist(key);
// Call the private method to assign a custom error message for the specified field
globalKeys[key]!.currentState!._assignCustomError(
errorMessage,
isRedrawState,
);
}