init static method
Future<void>
init({
- String? name,
- TranslationDelegate? delegate,
- TranslatorDelegate? translator,
- Set<
String> ? paths, - Set<
String> ? symmetricPaths, - bool connected = false,
- bool listening = true,
- bool showLogs = true,
- bool autoTranslateMode = true,
- VoidCallback? onReady,
- String defaultPath = kDefaultTranslationPath,
- Object? locale,
- Object? defaultLocale,
- Object? fallbackLocale,
- Iterable? supportedLocales,
Implementation
static Future<void> init({
String? name,
TranslationDelegate? delegate,
TranslatorDelegate? translator,
Set<String>? paths,
Set<String>? symmetricPaths,
bool connected = false,
bool listening = true,
bool showLogs = true,
bool autoTranslateMode = true,
VoidCallback? onReady,
String defaultPath = kDefaultTranslationPath,
Object? locale,
Object? defaultLocale,
Object? fallbackLocale,
Iterable? supportedLocales,
}) async {
i._defaultPath = defaultPath;
i.defaultLocaleOrNull = parseLocale(
defaultLocale ?? await delegate?.defaultLocale,
);
i.fallbackLocaleOrNull = parseLocale(fallbackLocale);
i.localeOrNull = parseLocale(locale);
i._supportedLocales = parseLocales(supportedLocales);
i._autoTranslateEnable = autoTranslateMode;
await i.initialize(
name: name ?? kDefaultTranslationName,
connected: connected,
delegate: delegate,
paths: {defaultPath, if (paths != null) ...paths},
symmetricPaths: {
defaultPath,
if (symmetricPaths != null) ...symmetricPaths,
},
listening: listening,
showLogs: showLogs,
onReady: () {
if (translator != null) {
i._translator = Translator(
defaultLocale: i.locale,
fallbackLocale: i.fallbackLocale,
delegate: translator,
);
}
if (onReady != null) onReady();
},
);
}