Runtime Locale Switching¶
anas_localization keeps locale changes explicit and context-bound.
Change the locale¶
Example button¶
ElevatedButton(
onPressed: () async {
await AnasLocalization.of(context).setLocale(const Locale('tr'));
},
child: const Text('Switch to Turkish'),
)
Read the current locale¶
Read the supported locales¶
Notes¶
- translation reads should come from the generated dictionary, typically
getDictionary() - locale switching should keep using
AnasLocalization.of(context) - widget tests should pump the app inside
AnasLocalization