LocalizedTextExt extension

Extension on the Text widget to facilitate the creation of text widgets with localized strings.

This extension adds methods to the Text widget that simplify the process of creating text with localized content from the localization provider. It leverages other extensions that must be defined on String to fetch localized content, like LocalizedStringExt.

Examples:

Text('hello').tr(context)
Text('welcome_message').trParams(context, params: {'userName': 'Alice'})
on

Methods

tr([BuildContext? context]) Text

Available on Text, provided by the LocalizedTextExt extension

Creates a Text widget with a localized string obtained from the given context.
trParams({required Map<String, dynamic> namedArgs, BuildContext? context}) Text

Available on Text, provided by the LocalizedTextExt extension

Creates a Text widget with a localized string obtained from the given context and formatted with parameters.
trPlural(int count, {BuildContext? context}) Text

Available on Text, provided by the LocalizedTextExt extension

Creates a text widget that displays pluralized localization of a text based on the provided count.