TranslatableText function
Text
TranslatableText({
- required Language displayLanguage,
- required List<
TranslateOption> options, - TextStyle? style,
- StrutStyle? strutStyle,
- TextAlign? textAlign,
- TextDirection? textDirection,
- Locale? locale,
- bool? softWrap,
- TextOverflow? overflow,
- double? textScaleFactor,
- int? maxLines,
- String? semanticsLabel,
- TextWidthBasis? textWidthBasis,
- TextHeightBehavior? textHeightBehavior,
Implementation
Text TranslatableText({
required Language displayLanguage,
required List<TranslateOption> options,
TextStyle? style,
StrutStyle? strutStyle,
TextAlign? textAlign,
TextDirection? textDirection,
Locale? locale,
bool? softWrap,
TextOverflow? overflow,
double? textScaleFactor,
int? maxLines,
String? semanticsLabel,
TextWidthBasis? textWidthBasis,
TextHeightBehavior? textHeightBehavior,
}){
int index = options.indexWhere((option) => option.language.languageName == displayLanguage.languageName);
//If the selected language is not found
String displayText = index == -1 ? 'Language not Supported': options[index].text;
return Text(
displayText,
locale: locale,
maxLines: maxLines,
overflow: overflow,
semanticsLabel: semanticsLabel,
softWrap: softWrap,
strutStyle: strutStyle,
style: style,
textAlign: textAlign,
textDirection: textDirection,
textHeightBehavior: textHeightBehavior,
textScaleFactor: textScaleFactor,
textWidthBasis: textWidthBasis,
);
}