LocaleSwitcher class

A Widget to switch locale of App.

Use any of these constructors to create widget:

Inheritance

Constructors

LocaleSwitcher.custom({Key? key, LocaleSwitchBuilder? builder, int numberOfShown = 4, bool showOsLocale = true})
A Widget to switch locale of App with your own widget:
const
LocaleSwitcher.grid({Key? key, SliverGridDelegate? gridDelegate, int numberOfShown = 200, bool showOsLocale = true, dynamic setLocaleCallBack(BuildContext)?, int useNLettersInsteadOfIcon = 0, ShapeBorder? shape = const CircleBorder(eccentricity: 0), bool useEmoji = false, bool multiLangForceAll = false, MultiLangCountries multiLangCountries = MultiLangCountries.onlyFlag, MultiLangBuilder? multiLangWidget, double specialFlagsPadding = 0})
A Widget to switch locale of App with GridView.
const
LocaleSwitcher.iconButton({Key? key, String? toolTipPrefix = 'Current language: ', bool useEmoji = false, String? title = 'Select language: ', Icon? useStaticIcon, double iconRadius = 32, int numberOfShown = 200, bool showOsLocale = true, int useNLettersInsteadOfIcon = 0, ShapeBorder? shape = const CircleBorder(eccentricity: 0), dynamic setLocaleCallBack(BuildContext)?, MultiLangCountries multiLangCountries = MultiLangCountries.auto, bool multiLangForceAll = false, MultiLangBuilder? multiLangWidget, double specialFlagsPadding = 0})
A Widget to switch locale of App with IconButton.
const
LocaleSwitcher.menu({Key? key, String? title = 'Language:', int numberOfShown = 200, bool showOsLocale = true, int useNLettersInsteadOfIcon = 0, bool useEmoji = false, double? width = 250, bool showLeading = true, ShapeBorder? shape = const CircleBorder(eccentricity: 0), dynamic setLocaleCallBack(BuildContext)?, bool multiLangForceAll = false, MultiLangCountries multiLangCountries = MultiLangCountries.onlyFlag, MultiLangBuilder? multiLangWidget, double iconRadius = 38, double specialFlagsPadding = 0})
A Widget to switch locale of App with DropDownMenu.
const
LocaleSwitcher.segmentedButton({Key? key, bool useEmoji = false, double? width, double iconRadius = 32, int numberOfShown = 4, bool showOsLocale = true, int useNLettersInsteadOfIcon = 0, ShapeBorder? shape, dynamic setLocaleCallBack(BuildContext)?, double specialFlagsPadding = 2, bool multiLangForceAll = false, MultiLangCountries multiLangCountries = MultiLangCountries.auto, MultiLangBuilder? multiLangWidget})
A Widget to switch locale of App with SegmentedButton.
const

Properties

builder LocaleSwitchBuilder?
Create you own locale switcher widget:
final
gridDelegate SliverGridDelegate?
Only for LocaleSwitcher.grid constructor
final
hashCode int
The hash code for this object.
no setterinherited
iconRadius double
Only for LocaleSwitcher.iconButton.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
multiLangCountries MultiLangCountries
How to display Locales for countries with multiple languages:
final
multiLangForceAll bool
Force all Locales to be displayed as MultiLangCountries.
final
multiLangWidget MultiLangBuilder?
Custom builder function to display Locales for countries with multiple languages,
final
numberOfShown int
Number of shown flags
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
setLocaleCallBack → (dynamic Function(BuildContext)?)
Function called after choosing new current Locale (actually LocaleName).
final
shape ShapeBorder?
Shape of flags.
final
showLeading bool
Show leading icon in drop down menu
final
showOsLocale bool
Show option to use language of OS.
final
specialFlagsPadding double
Padding for special icons (systemLocale, showOtherLocales).
final
title String?
Currently selected entry in supportedLocaleNames that contains Locale.
final
toolTipPrefix String?
Only for LocaleSwitcher.iconButton.
final
type LocaleSwitcherType
What constructor was used to create this instance.
final
useEmoji bool
Use Emoji instead of svg flag.
final
useNLettersInsteadOfIcon int
If null or 0 - used Icon, otherwise first N letters of language code.
final
useStaticIcon Icon?
Only for LocaleSwitcher.iconButton - use static icon.
final
width double?
Just width of the widget.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<LocaleSwitcher>
Creates the mutable state for this widget at a given location in the tree.
override
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}) 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

Static Properties

current LocaleName
Currently selected entry in supportedLocaleNames that contains Locale.
getter/setter pair
locale ValueNotifier<Locale>
A ReadOnly ValueNotifier with current locale.
no setter
localeBestMatch Locale
A ReadOnly Locale, in range of supportedLocales, if selected systemLocale it try to guess.
no setter
localeIndex ValueNotifier<int>
ValueNotifier with index of currently used LocaleName in list supportedLocaleNames.
no setter
supportedLocaleNames SupportedLocaleNames
A list of generated LocaleNames for supportedLocales.
no setter

Static Methods

readLocales(List<Locale> supportedLocales) List<Locale>
Update supportedLocales (that used to generated LocaleStore.supportedLocaleNames).