textWithOptions method

String textWithOptions({
  1. TranslationButtonType type = TranslationButtonType.flagAndNameInEn,
  2. bool markAsDefault = false,
  3. TextureIcons selectedIcon = TextureIcons.none,
})

Returns a text representation of the Locale with custom options.

Parameters:

  • type: Determines how the locale is displayed (flag, name, code, or combination). Defaults to TranslationButtonType.flagAndNameInEn.
  • markAsDefault: If true and the locale matches the app default, appends "(Default)" to the text.
  • selectedIcon: Optionally appends a custom icon if the locale is currently selected.

Example usage:

Locale locale = Locale('es', 'ES');
String text1 = locale.text; // Uses default type (flag + English name)
String text2 = locale.textWithOptions(
  type: TranslationButtonType.flagAndName,
  markAsDefault: true,
  selectedIcon: TextureIcons.check,
);
print(text2); // Output: "🇪🇸  Español (Default) ✔"

Implementation

String textWithOptions({
  TranslationButtonType type = TranslationButtonType.flagAndNameInEn,
  bool markAsDefault = false,
  TextureIcons selectedIcon = TextureIcons.none,
}) {
  return type.text(
    this,
    markAsDefault: markAsDefault,
    selectedIcon: selectedIcon,
  );
}