Solution 1 :
simply just put the path of the folder where localization files are, in my case.
flutter pub run easy_localization:generate --source-dir ./assets/translations
Solution 2 :
In case someone get the same error while generating locale_keys.g.dart
use the below code:
flutter pub run easy_localization:generate -S assets/translations -f keys -o locale_keys.g.dart
Solution 3 :
try the following code :
flutter pub run easy_localization:generate -s assets/translations
Solution 4 :
Remove /(forwad slash symbol) from path
Like
path:”assets/translations”
that’s it.
Solution 5 :
Make sure translations file path is given properly in below command, also add
locale_keys.g.dart
to generate a file with the same name.
flutter pub run easy_localization:generate --source-dir ./assets/translations -f keys -o locale_keys.g.dart
Usage:
import 'package:easy_localization/easy_localization.dart';
LocaleKeys.Name /// Similar way find your keys which declared inside .json file
Solution 6 :
try the following code:
flutter pub run easy_localization:generate -O lib/core/lang -f keys -o locale_keys.g.dart --source-dir ./assets/lang
Problem :
I’m trying to add Spanish to my flutter project with easy_localization i added JSON files of US and ES and added the path to it in runApp function as I try to generate keys with flutter
pub run easy_localization:generate
runApp(EasyLocalization(
supportedLocales: [Locale('en', 'US'), Locale('es', 'ES')],
path: 'assets/translations/',
fallbackLocale: Locale('en', 'US'),
child: MyApp()));
Comments
Comment posted by Kamlesh
I am using
Comment posted by Sunil Chaudhary
String text = textwith_slash.replace(“/*”,””);
Comment posted by Kamlesh
how can we do this with