this is how my code is structured but I'm getting null when I call KLocalizations.of(context);
const supportedLocales = [ Locale('en', 'GB'), Locale('de', 'DE'), ];
void main() {
runApp(
KLocalizations.asChangeNotifier(
locale: supportedLocales[0],
defaultLocale: supportedLocales[0],
supportedLocales: supportedLocales,
child: Phoenix(child: const MainApp(),
),
),
);
}
GlobalKey navigatorKey = GlobalKey();
class MainApp extends StatefulWidget {
const MainApp({Key? key}) : super(key: key);
@OverRide
_MainAppState createState() => _MainAppState();
}
class _MainAppState extends State {
LocaleProvider provider = LocaleProvider();
bool _isOldUserShowed = false;
@OverRide void initState() {
_initLanguage();
provider.addListener(() { setState(() {}); });
super.initState();
}
@OverRide Widget build(BuildContext context) {
final klocalizations = KLocalizations.of(context);
print(klocalizations);