getMessageSource abstract method
Returns the configured MessageSource.
Provides access to the internationalization infrastructure for resolving localized messages throughout the application.
Throws:
IllegalStateException
if the message source has not been initialized
Example:
// Access message source directly
final messages = context.getMessageSource();
// Resolve messages with different strategies
final welcomeMsg = messages.getMessage(
'user.welcome',
args: ['John'],
locale: Locale('en', 'US')
);
final errorMsg = messages.getMessage(
'validation.email.invalid',
defaultMessage: 'Please enter a valid email address'
);
// Use in exception messages
throw ValidationException(
messages.getMessage('error.validation.failed')
);
// Use in logging with localization
logger.info(messages.getMessage('app.startup.complete'));
Implementation
MessageSource getMessageSource();