main function
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
Implementation
// V. MAIN APP ENTRY POINT
////////////////////////////////////////////////////////////////////////////////////
Future<void> main() async {
debugPrint("[DEBUG] App initialization started at ${DateTime.now()}");
HttpOverrides.global = MyHttpOverrides();
debugPrint("[DEBUG] HTTP Overrides configured");
WidgetsFlutterBinding.ensureInitialized();
debugPrint("[DEBUG] Flutter binding initialized");
// Initialize Firebase
debugPrint("[DEBUG] Initializing Firebase...");
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
debugPrint("[DEBUG] Firebase initialized at ${DateTime.now()}");
// Initialize persistence services
debugPrint("[DEBUG] Initializing persistence services...");
await initializePersistenceServices();
debugPrint("[DEBUG] Persistence services initialized");
// Load environment variables
debugPrint("[DEBUG] Loading environment variables...");
final env = await loadEnvFromServer();
debugPrint("[DEBUG] Environment variables loaded: ${env.keys.length} keys found");
final token = env['MAPBOX_PUBLIC_ACCESS_TOKEN'];
if (token == null) {
debugPrint("[DEBUG] ERROR: Mapbox token not found in environment");
throw Exception('Mapbox token not found');
}
debugPrint("[DEBUG] Mapbox token successfully loaded");
MapboxOptions.setAccessToken(token);
debugPrint("[DEBUG] Mapbox access token set");
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive, overlays: []);
debugPrint("[DEBUG] System UI mode set to immersive");
// Verify assets are available
debugPrint("[DEBUG] Verifying assets availability...");
final assetPath = "assets/logo-300px.png";
debugPrint("[DEBUG] Splash screen asset path: $assetPath");
debugPrint("[DEBUG] App initialization completed at ${DateTime.now()}");
runApp(RALIApp(env: env));
}