I´am trying to get the mobile countryCode and languageCode using Localizations
Widget build(BuildContext context) {
Locale myLocale = Localizations.localeOf(context);
print(myLocale.countryCode);
print(myLocale.languageCode);
return MaterialApp(
title: 'Title',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: LoginPage(),
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
Locale('es' 'ES'),
],
);
}
But return "Localizations ancestor was not found".Somebody know what is the correct way to do this?