build abstract method
Widget
build(
- BuildContext context,
- WidgetRef ref,
- Locale state,
- LanguageSwitcherNotifier notifier,
- List<
LocaleInfo> supportedLocales,
Build method that concrete implementations must override.
This method receives all necessary data for building language switcher UI:
context
: The build context for accessing theme and navigationref
: WidgetRef for accessing Riverpod providersstate
: Current locale state from the language switcher providernotifier
: LanguageSwitcherNotifier for changing localessupportedLocales
: List of all supported locales from app configuration
Example implementation:
@override
Widget build(
BuildContext context,
WidgetRef ref,
Locale state,
LanguageSwitcherNotifier notifier,
List<LocaleInfo> supportedLocales,
) {
return Column(
children: supportedLocales.map((localeInfo) {
return RadioListTile<Locale>(
value: localeInfo.locale,
groupValue: state,
title: Text(localeInfo.displayName),
onChanged: (locale) {
if (locale != null) notifier.changeLocale(locale);
},
);
}).toList(),
);
}
Implementation
Widget build(
BuildContext context,
WidgetRef ref,
Locale state,
LanguageSwitcherNotifier notifier,
List<LocaleInfo> supportedLocales,
);