HierarchicalMessageSource class abstract interface

A MessageSource that asks a parent message source for the codes it does not have.

A child context's message source gets the parent context's as its parent automatically. Set one yourself to share common texts between several sources.

// A feature's messages, with the shared ones as fallback.
final common = StaticMessageSource()..addMessage('ok', '', 'OK');
final feature = StaticMessageSource()..parentMessageSource = common;
feature.getMessage('ok'); // 'OK' from the parent

Spring (Java):

var feature = new StaticMessageSource();
feature.setParentMessageSource(common);
Implemented types

Properties

hashCode → int
The hash code for this object.
no setterinherited
parentMessageSource ↔ MessageSource?
The source asked when this one has no message for a code; null for none.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

getMessage(String code, {List<Object?> args = const [], String? defaultMessage, String? locale}) → String
The text for code in locale, with args filled into its {0}, {1}, ... placeholders.
inherited
getMessageFromResolvable(MessageSourceResolvable resolvable, {String? locale}) → String
The text for the first code of resolvable found in locale, with its arguments filled in; else its default message; else a NoSuchMessageException. Use it to show validation errors and other messages described by codes.
inherited
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