49 lines
1.7 KiB
Dart
49 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get_storage/get_storage.dart';
|
|
import 'package:sigap/app.dart';
|
|
import 'package:sigap/src/cores/repositories/panic/panic_button_repository.dart';
|
|
import 'package:sigap/src/cores/services/biometric_service.dart';
|
|
import 'package:sigap/src/cores/services/location_service.dart';
|
|
import 'package:sigap/src/cores/services/supabase_service.dart';
|
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
|
|
|
Future<void> main() async {
|
|
// Ensure that the Flutter binding is initialized before calling any Flutter
|
|
final WidgetsBinding widgetBinding =
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// -- GetX Local Storage
|
|
await GetStorage.init();
|
|
|
|
// -- Await splash until other item load
|
|
FlutterNativeSplash.preserve(widgetsBinding: widgetBinding);
|
|
|
|
// Initialize the authentication repository with Supabase
|
|
await Supabase.initialize(
|
|
url: dotenv.env['SUPABASE_URL']!,
|
|
anonKey: dotenv.env['SUPABASE_ANON_KEY']!,
|
|
authOptions: const FlutterAuthClientOptions(
|
|
authFlowType: AuthFlowType.pkce,
|
|
// detectSessionInUri: true,
|
|
),
|
|
realtimeClientOptions: RealtimeClientOptions(
|
|
logLevel: RealtimeLogLevel.info,
|
|
),
|
|
storageOptions: const StorageClientOptions(retryAttempts: 10),
|
|
);
|
|
|
|
// Initialize services
|
|
await Get.putAsync(() => SupabaseService().init());
|
|
await Get.putAsync(() => BiometricService().init());
|
|
await Get.putAsync(() => LocationService().init());
|
|
|
|
// Initialize repositories
|
|
Get.put(PanicButtonRepository());
|
|
await Get.find<PanicButtonRepository>().init();
|
|
|
|
runApp(const App());
|
|
}
|