LocalizedText class

A Text widget that displays a localized string and automatically rebuilds when the locale changes.

// Simple key lookup
LocalizedText('ui.start_game')

// With variable interpolation
LocalizedText('game.greeting', args: {'name': 'Aria'})

// Override style
LocalizedText('ui.title', style: Theme.of(context).textTheme.headlineMedium)
Inheritance

Constructors

LocalizedText(String key_, {Key? key, Map<String, Object?> args = const {}, String? ns, TextStyle? style, TextAlign? textAlign, int? maxLines, TextOverflow? overflow, bool softWrap = true})
The string for key_ in the nearest LocalizationScope's current locale, with args filled in and the lookup kept to ns when given. Shows nothing without a scope. The rest are Text's own parameters.
const

Properties

args → Map<String, Object?>
Variable substitution arguments.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
key_ → String
Localization key. Named key_ to avoid shadowing Widget.key.
final
maxLines → int?
Passed to Text.maxLines; the ambient default (usually no limit) when null.
final
ns → String?
Restrict lookup to one namespace.
final
overflow → TextOverflow?
Passed to Text.overflow; the ambient default when null.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
softWrap → bool
Passed to Text.softWrap: whether lines may break at word boundaries. True by default.
final
style → TextStyle?
Passed to Text.style; merged over the ambient DefaultTextStyle.
final
textAlign → TextAlign?
Passed to Text.textAlign; the ambient default when null.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

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