EasyLocalization class

EasyLocalization example:

void main(){
  runApp(EasyLocalization(
    child: MyApp(),
    supportedLocales: [Locale('en', 'US'), Locale('ar', 'DZ')],
    path: 'resources/langs/langs.csv',
    assetLoader: CsvAssetLoader()
  ));
}
Inheritance

Constructors

EasyLocalization({Key? key, required Widget child, required List<Locale> supportedLocales, required String path, Locale? fallbackLocale, Locale? startLocale, bool useOnlyLangCode = false, bool useFallbackTranslations = false, AssetLoader assetLoader = const RootBundleAssetLoader(), List<AssetLoader>? extraAssetLoaders, bool saveLocale = true, Widget errorWidget(FlutterError? message)?})

Properties

assetLoader AssetLoader
Class loader for localization files. You can use custom loaders from Easy Localization Loader or create your own class. @Default value const RootBundleAssetLoader()
final
child Widget
Place for your main page widget.
final
errorWidget → (Widget Function(FlutterError? message)?)
Shows a custom error widget when an error is encountered instead of the default error widget. @Default value errorWidget = ErrorWidget()
final
extraAssetLoaders List<AssetLoader>?
Class loader for localization files that belong to other packages. You can use custom loaders from Easy Localization Loader or create your own class. Example:
final
fallbackLocale Locale?
Locale when the locale is not in the list
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
path String
Path to your folder with localization files. Example:
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
saveLocale bool
Save locale in device storage. @Default value true
final
startLocale Locale?
Overrides device locale.
final
supportedLocales List<Locale>
List of supported locales. The list of locales that this app has been localized for.
final
useFallbackTranslations bool
If a localization key is not found in the locale file, try to use the fallbackLocale file. @Default value false Example:
final
useOnlyLangCode bool
Trigger for using only language code for reading localization files. @Default value false Example:
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _EasyLocalizationState
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

logger ↔ EasyLogger
Customizable logger
getter/setter pair

Static Methods

ensureInitialized() Future<void>
ensureInitialized needs to be called in main so that savedLocale is loaded and used from the start.
of(BuildContext context) → _EasyLocalizationProvider?