48 lines
1.4 KiB
Dart
48 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
|
|
|
import 'core/di/injection_container.dart';
|
|
import 'presentation/screens/splash_screen.dart';
|
|
|
|
void main() async {
|
|
try {
|
|
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
|
|
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
|
|
|
|
// Initialize dependency injection
|
|
await initializeDependencies();
|
|
|
|
runApp(const CodaApp());
|
|
} catch (e) {
|
|
debugPrint('CRITICAL INITIALIZATION ERROR: $e');
|
|
// If initialization fails, show a simple error screen instead of a broken app
|
|
runApp(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Text(
|
|
'Failed to start the app. Please try: \n1. flutter clean\n2. flutter pub get\n\nError: $e',
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(color: Colors.red),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
// Ensure splash is removed so user can see the error
|
|
FlutterNativeSplash.remove();
|
|
}
|
|
}
|
|
|
|
class CodaApp extends StatelessWidget {
|
|
const CodaApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(debugShowCheckedModeBanner: false, home: SplashScreen());
|
|
}
|
|
}
|