AbstractMessageSource class abstract

Base implementation of MessageSource providing common functionality.

This abstract class implements shared behavior like placeholder substitution and fallback locale resolution, allowing concrete implementations to focus on message loading and storage.

Key features:

  • Placeholder substitution with {0}, {1}, etc.
  • Locale fallback chain resolution
  • Message formatting utilities

Example subclass:

class MyMessageSource extends AbstractMessageSource {
  @override
  String? resolveMessage(String code, Locale locale) {
    // Custom message resolution logic
    return myMessages[locale]?[code];
  }
}
Implemented types
Implementers

Constructors

AbstractMessageSource({Locale? defaultLocale})
Base implementation of MessageSource providing common functionality.

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

formatMessage(String template, List<Object> args) String
Format message by substituting placeholders with arguments.
getDefaultLocale() → Locale
Get the default locale
getFallbackLocales(Locale locale) List<Locale>
Get the fallback locale chain for the given locale.
getMessage(String code, {List<Object>? args, Locale? locale, String? defaultMessage}) String
Retrieve a message for the given code.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolveMessage(String code, Locale locale) String?
Resolve a message for the given code and locale.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited