You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.8 KiB
Dart
92 lines
2.8 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hmg_nurses/config/routes.dart';
|
|
import 'package:hmg_nurses/provider/dashboard_provider_model.dart';
|
|
import 'package:hmg_nurses/theme/app_theme.dart';
|
|
import 'package:logger/logger.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:provider/single_child_widget.dart';
|
|
import 'package:sizer/sizer.dart';
|
|
|
|
import 'generated/codegen_loader.g.dart';
|
|
|
|
|
|
GlobalKey<NavigatorState> navigatorKey = GlobalKey();
|
|
|
|
Logger logger = Logger(
|
|
// filter: null, // Use the default LogFilter (-> only log in debug mode)
|
|
printer: PrettyPrinter(
|
|
lineLength: 0,
|
|
), // Use the PrettyPrinter to format and print log
|
|
// output: null, // U
|
|
);
|
|
|
|
class MyHttpOverrides extends HttpOverrides {
|
|
@override
|
|
HttpClient createHttpClient(SecurityContext? context) {
|
|
return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
|
|
}
|
|
}
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await EasyLocalization.ensureInitialized();
|
|
// AppState().setPostParamsInitConfig();
|
|
HttpOverrides.global = MyHttpOverrides();
|
|
runApp(
|
|
EasyLocalization(
|
|
supportedLocales: const <Locale>[
|
|
Locale('en', 'US'),
|
|
Locale('ar', 'SA'),
|
|
],
|
|
path: 'assets/langs',
|
|
assetLoader: const CodegenLoader(),
|
|
child: MultiProvider(
|
|
providers: <SingleChildWidget>[
|
|
ChangeNotifierProvider<DashboardProviderModel>(
|
|
create: (_) => DashboardProviderModel(),
|
|
)
|
|
],
|
|
child: const MyApp(),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// todo terminal command to generate translation files
|
|
// flutter pub run easy_localization:generate --source-dir ./assets/langs
|
|
// todo terminal command to generate translation keys
|
|
// flutter pub run easy_localization:generate --source-dir ./assets/langs -f keys -o locale_keys.g.dart
|
|
// command to generate languages data from json
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Sizer(
|
|
builder: (
|
|
BuildContext context,
|
|
Orientation orientation,
|
|
DeviceType deviceType,
|
|
) {
|
|
List<LocalizationsDelegate<dynamic>> delegates = context.localizationDelegates;
|
|
return MaterialApp(
|
|
key: navigatorKey,
|
|
theme: AppTheme.getTheme(
|
|
EasyLocalization.of(context)?.locale.languageCode == "ar",
|
|
),
|
|
debugShowCheckedModeBanner: false,
|
|
localizationsDelegates: delegates,
|
|
supportedLocales: context.supportedLocales,
|
|
locale: context.locale,
|
|
initialRoute: AppRoutes.login,
|
|
routes: AppRoutes.routes,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|