2023-02-27 07:12:45 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
2023-03-29 12:30:58 +00:00
|
|
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
2023-02-27 07:12:45 +00:00
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
|
|
import 'app/app.dart';
|
2023-03-28 06:36:10 +00:00
|
|
|
import 'app/core/utils/notification_service.dart';
|
2023-02-27 07:12:45 +00:00
|
|
|
|
|
|
|
|
DBHelper dbHelper = DBHelper();
|
|
|
|
|
|
2023-03-29 12:30:58 +00:00
|
|
|
Future<void> _initAppInitials() async {
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
|
|
// HttpOverrides.global = MyHttpOverrides();
|
|
|
|
|
|
|
|
|
|
await ScreenUtil.ensureScreenSize();
|
|
|
|
|
|
|
|
|
|
await initLoginStatus();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-28 06:36:10 +00:00
|
|
|
// Firebase initials is separated, app needs to be initialized
|
|
|
|
|
// regardless Firebase
|
|
|
|
|
Future<void> _initFBInitials() async {
|
2023-03-29 12:30:58 +00:00
|
|
|
try {
|
|
|
|
|
await initFCMFunctions();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
debugPrint('FCM error: $e');
|
|
|
|
|
}
|
2023-03-28 06:36:10 +00:00
|
|
|
}
|
|
|
|
|
|
2023-02-27 07:12:45 +00:00
|
|
|
Future<void> main() async {
|
2023-03-29 12:30:58 +00:00
|
|
|
await _initAppInitials();
|
2023-02-27 07:12:45 +00:00
|
|
|
|
2023-03-29 12:30:58 +00:00
|
|
|
final String locale = await getLocale();
|
2023-02-27 07:12:45 +00:00
|
|
|
|
2023-03-29 12:30:58 +00:00
|
|
|
FlutterNativeSplash.remove();
|
2023-02-27 07:12:45 +00:00
|
|
|
|
2023-03-29 12:30:58 +00:00
|
|
|
// FB functions needs to init after
|
|
|
|
|
/// [FlutterNativeSplash.remove()]
|
|
|
|
|
await _initFBInitials();
|
2023-02-27 07:12:45 +00:00
|
|
|
|
2023-03-29 12:30:58 +00:00
|
|
|
runApp(ElektronikaShopApp(lang: locale));
|
2023-02-27 07:12:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ElektronikaShopApp extends StatelessWidget {
|
|
|
|
|
final String? lang;
|
|
|
|
|
|
|
|
|
|
ElektronikaShopApp({required this.lang});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
|
DeviceOrientation.portraitUp,
|
|
|
|
|
DeviceOrientation.portraitDown,
|
|
|
|
|
]);
|
|
|
|
|
return LayoutBuilder(
|
|
|
|
|
builder: (BuildContext context, BoxConstraints constraints) {
|
|
|
|
|
return ScreenUtilInit(
|
|
|
|
|
designSize: Size(constraints.maxWidth, constraints.maxHeight),
|
|
|
|
|
builder: (_, child) => GetMaterialApp(
|
|
|
|
|
initialRoute: lang == null ? AppRoutes.SPLASH : AppRoutes.DASHBOARD,
|
|
|
|
|
getPages: AppPages.list,
|
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
|
locale: lang == null ? Locale('tm', 'TM') : Locale(lang!, lang!.toUpperCase()),
|
|
|
|
|
fallbackLocale: LocalizationService.fallbackLocale,
|
|
|
|
|
translations: LocalizationService(),
|
|
|
|
|
theme: AppTheme.light,
|
|
|
|
|
darkTheme: AppTheme.dark,
|
|
|
|
|
themeMode: ThemeMode.light, // ThemeMode.system
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// cd ios
|
|
|
|
|
//arch -x86_64 pod install
|
|
|
|
|
//arch -x86_64 pod install --repo-update
|