🐛 Fix: Handle Firebase initialization failures gracefully - Wrapped Firebase.initializeApp() in try-catch - App now works even if Firebase isn't configured - Added helpful error messages pointing to FIREBASE_SETUP.md - Household creation shows clear error if Firebase fails ⚠️ User Experience: - If Firebase not configured: Shows error message - Error message guides user to setup instructions - App doesn't crash, continues with local-only mode ✅ Testing: - APK builds successfully (63.3MB) - App runs without Firebase configuration - Error messages are user-friendly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'core/constants/app_theme.dart';
|
|
import 'data/local/hive_database.dart';
|
|
import 'features/home/screens/home_screen.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// Initialize Firebase (gracefully handle if not configured)
|
|
try {
|
|
await Firebase.initializeApp();
|
|
print('✅ Firebase initialized successfully');
|
|
} catch (e) {
|
|
print('⚠️ Firebase initialization failed: $e');
|
|
print('Household sharing will not work without Firebase configuration.');
|
|
print('See FIREBASE_SETUP.md for setup instructions.');
|
|
}
|
|
|
|
// Initialize Hive database
|
|
await HiveDatabase.init();
|
|
|
|
runApp(
|
|
const ProviderScope(
|
|
child: SageApp(),
|
|
),
|
|
);
|
|
}
|
|
|
|
class SageApp extends StatelessWidget {
|
|
const SageApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Sage 🌿',
|
|
debugShowCheckedModeBanner: false,
|
|
theme: AppTheme.lightTheme,
|
|
darkTheme: AppTheme.darkTheme,
|
|
themeMode: ThemeMode.light, // We'll make this dynamic later
|
|
home: const HomeScreen(),
|
|
);
|
|
}
|
|
}
|