I am trying to make my app support localization. I want my app to work in 2 languages: English & Hindi. So i added the following package in my pubspec.yaml:
flutter_localizations:
sdk: flutter
intl: ^0.17.0 # Add this line
Then i made a l10n.yaml file and added this:
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
I also made the app_en.arb file like this:
{
"helloWorld": "Hello World!",
"@helloWorld": {
"description": "The conventional newborn programmer greeting"
}
}
When i am running this code, it gives me an error:
Generating synthetic localizations package failed with 1 error:
Exception: The 'template-arb-file', LocalFile: 'C:\Users\Crosslynx25\Desktop\SW_Mobile_Platform\lib/l10n\app_en.arb', is not readable.
Please ensure that the user has read permissions.
main.dart file
import 'package:ble_app_flutter/screens/home_screen.dart';
import 'package:ble_app_flutter/screens/otp_screen.dart';
import 'package:ble_app_flutter/screens/splash_screen.dart';
import 'package:ble_app_flutter/utils/colors.dart';
import 'package:ble_app_flutter/l10n/L10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:lottie/lottie.dart';
import 'country_codes.dart'
as CountryCodes;
import 'screens/driver/driver_home_screen.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
State < MyApp > createState() => _MyAppState();
}
Map < int, Color > myTheme = {
50: Color.fromRGBO(9, 65, 155, .1),
100: Color.fromRGBO(9, 65, 155, .2),
};
class _MyAppState extends State < MyApp > {
// This widget is the root of your application.
MaterialColor myColor = MaterialColor(0xFF09419b, myTheme);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'BLE App gkhglkjhkl',
debugShowCheckedModeBanner: false,
supportedLocales: L10n.all,
// localizationsDelegates: [
// AppLocalizations.delegate, // Add this line
// GlobalMaterialLocalizations.delegate,
// GlobalWidgetsLocalizations.delegate,
// GlobalCupertinoLocalizations.delegate,
// ],
theme: ThemeData(
primarySwatch: myColor,
),
home: new Login(),
);
}
}
class Login extends StatefulWidget {
@override
State < Login > createState() => _LoginState();
}
class _LoginState extends State < Login > {
// const Login({
var selectedCountry = "91";
var phoneNumber = "";
@override
Widget build(BuildContext context) {
.
. //some code
.
}
}
main.dartfile, please check.