I've this app with flutter 3.0 and easy_localization 3.0.2 package. I want to set a default language at boot of the app. I use startLocale: Locale('ru', 'RU') but it seem not function. It use the language that is set in the context in the previous execution of the app. How can i solve this problem?
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'generated/locale_keys.g.dart';
import 'lang_view.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
runApp(EasyLocalization(
supportedLocales: [
Locale('en', 'US'),
Locale('ar', 'DZ'),
Locale('de', 'DE'),
Locale('ru', 'RU'),
Locale('it', 'IT')
],
startLocale: Locale('ru', 'RU'),
path: 'resources/langs',
child: MyApp(),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: '/',
routes: {
// When navigating to the "/" route, build the FirstScreen widget.
'/': (context) => MyHomePage(title: 'Easy localization'),
// When navigating to the "/second" route, build the SecondScreen widget.
'/second': (context) => const SecondPage(),
},
);
}
}```