LocaleManager class

(en) A InheritedWidget for controlling locale within an app. /// Any widget that calls LocaleManager.of(context) from this class will automatically be rebuilt and updated when the locale is changed.

(ja) アプリ内でロケールをコントロールするためのInheritedWidgetです。 このクラスのLocaleManager.of(context)を呼び出したウィジェットは、 ロケールが変更されると自動で再ビルドされて反映されます。

Inheritance

Constructors

LocaleManager({required ValueNotifier<Locale> localeNotifier, required List<Locale> supportedLocales, required Locale? defLocale, required Widget child, Key? key})
(en) Note: Do not call this constructor directly. This is meant to be called via LocalizedApp.

Properties

appLocale → LocaleParams
final
child Widget
The widget below this widget in the tree.
finalinherited
defLocale Locale?
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
localeNotifier ValueNotifier<Locale>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedLocales List<Locale>
final

Methods

changeLocale(Locale locale) → void
(en) Change the app locale. If you try to set an unsupported locale, nothing happens.
createElement() InheritedElement
Inflates this configuration to a concrete instance.
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
getLanguageCode() String
(en) Gets the current language code for the app.
getLocale() Locale
(en) Get now app locale.
getLocaleForApp() Locale?
(en) Get now app locale. This method returns null until changeLocale is called. In other words, if you use it as the locale for a MaterialApp or CupertinoApp, changes to the device's locale will be effective while the app is running until changeLocale is called. However, if defLocale is set, it takes precedence.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
(en)Initializes the locale settings. Normally, it is initialized with the device's own locale, but if the device locale is not included in allowedLocales, fallbackLocale will be set. If defLocale is set, calculations will be performed with defLocale as the top priority. The locale set by changeLocale will be cleared when this is called.
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
updateShouldNotify(covariant LocaleManager oldWidget) bool
Whether the framework should notify widgets that inherit from this widget.
override

Operators

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

Static Methods

of(BuildContext context) LocaleManager?
(en) Widgets that access locale information via this method will be tracked for changes and will be rebuilt when the locale changes.