ErrorMessageFormatter<E> class
abstract
Formats validation errors into user-facing messages.
Implement this to provide reusable error formatting logic.
Example
enum AuthError { empty, invalidEmail }
class AuthErrorFormatter extends ErrorMessageFormatter<AuthError> {
const AuthErrorFormatter();
@override
String format(AuthError error) {
return switch (error) {
AuthError.empty => 'Email is required',
AuthError.invalidEmail => 'Invalid email address',
};
}
}
Constructors
- ErrorMessageFormatter()
-
Creates an error message formatter.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
format(
E error) → String -
Returns the user-facing message for
error. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited