LocaleSwitcher.custom constructor

const LocaleSwitcher.custom({
  1. Key? key,
  2. LocaleSwitchBuilder? builder,
  3. int numberOfShown = 4,
  4. bool showOsLocale = true,
})

A Widget to switch locale of App with your own widget:

Example:

LocaleSwitcher.custom(
  builder: (supportedLocNames, context) { // widget AnimatedToggleSwitch from package:
    return AnimatedToggleSwitch<LocaleName>.rolling( // animated_toggle_switch
      current: LocaleSwitcher.current,
      values: supportedLocNames,
      loading: false,
      onChanged: (curLocaleName) {
        if (curLocaleName.name == showOtherLocales)
          showSelectLocaleDialog(context);
        } else {
          LocaleSwitcher.current = curLocaleName;
          // next for easy_localization with locale_switcher ONLY - NOT for locale_switcher_dev !
          // context.setLocale(LocaleSwitcher.localeBestMatch);
        }
      },
      iconBuilder: LangIconWithToolTip.forIconBuilder,
    );
  })

Implementation

const LocaleSwitcher.custom({
  super.key,
  this.builder,
  this.numberOfShown = 4,
  this.showOsLocale = true,
})  : type = LocaleSwitcherType.custom,
      title = '',
      useStaticIcon = null,
      toolTipPrefix = '',
      showLeading = true,
      gridDelegate = null,
      useEmoji = false,
      multiLangForceAll = false,
      multiLangWidget = null,
      multiLangCountries = MultiLangCountries.auto,
      specialFlagsPadding = 0,
      shape = const CircleBorder(eccentricity: 0),
      iconRadius = 32,
      setLocaleCallBack = null,
      width = null,
      useNLettersInsteadOfIcon = 0;