88 lines
2.8 KiB
Dart
88 lines
2.8 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
import 'package:flutter_stripe/flutter_stripe.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get_storage/get_storage.dart';
|
|
import 'package:ride/constant/box_name.dart';
|
|
import 'package:ride/constant/credential.dart';
|
|
import 'package:ride/constant/info.dart';
|
|
import 'package:ride/splash_screen_page.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'controller/firebase/firbase_messge.dart';
|
|
import 'controller/local/local_controller.dart';
|
|
import 'controller/local/translations.dart';
|
|
import 'firebase_options.dart';
|
|
import 'models/db_sql.dart';
|
|
|
|
final box = GetStorage();
|
|
const storage = FlutterSecureStorage();
|
|
DbSql sql = DbSql.instance;
|
|
@pragma('vm:entry-point')
|
|
Future<void> backgroundMessageHandler(RemoteMessage message) async {
|
|
await Firebase.initializeApp();
|
|
print('===========back===${message.notification?.title}');
|
|
|
|
if (message.notification!.title == 'Sefer') {}
|
|
}
|
|
|
|
// late List<CameraDescription> cameras;
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await GetStorage.init();
|
|
if (box.read(BoxName.apiKeyRun).toString() != 'run') {
|
|
await AppCredintials().getApiKey();
|
|
}
|
|
String? stripePublishableKey =
|
|
await storage.read(key: BoxName.stripePublishableKey);
|
|
Stripe.publishableKey = stripePublishableKey ?? '';
|
|
//StripeKey.publishableKey;
|
|
if (Platform.isAndroid || Platform.isIOS) {
|
|
await Firebase.initializeApp(
|
|
options: DefaultFirebaseOptions.currentPlatform,
|
|
);
|
|
await FirebaseMessagesController().requestFirebaseMessagingPermission();
|
|
|
|
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
|
|
|
|
List<Future> initializationTasks = [
|
|
FirebaseMessagesController().getNotificationSettings(),
|
|
FirebaseMessagesController().getToken(),
|
|
];
|
|
// cameras = await availableCameras();
|
|
await Future.wait(initializationTasks);
|
|
}
|
|
SystemChrome.setPreferredOrientations([
|
|
DeviceOrientation.portraitUp,
|
|
DeviceOrientation.portraitDown,
|
|
]);
|
|
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
// This widget is the root of your application.
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
LocaleController localController = Get.put(LocaleController());
|
|
|
|
return GetMaterialApp(
|
|
title: AppInformation.appName,
|
|
translations: MyTranslation(),
|
|
debugShowCheckedModeBanner: false,
|
|
locale: localController.language,
|
|
theme: localController.appTheme,
|
|
key: UniqueKey(),
|
|
// routes: {'/':const HomePage()},
|
|
// home: LoginCaptin());
|
|
home: SplashScreen());
|
|
}
|
|
}
|