- Updated main.dart with proper Supabase initialization - Added environment loading with error handling - Replaced default Flutter template with Sage app - Created simple HomePage with Supabase connection status - Used debugPrint instead of print for production compliance
86 lines
2.2 KiB
Dart
86 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'core/constants/supabase_constants.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
try {
|
|
// Load environment variables
|
|
await SupabaseConstants.initialize();
|
|
|
|
// Initialize Supabase
|
|
await Supabase.initialize(
|
|
url: SupabaseConstants.supabaseUrl,
|
|
anonKey: SupabaseConstants.supabaseAnonKey,
|
|
);
|
|
|
|
debugPrint('Supabase initialized successfully');
|
|
} catch (e) {
|
|
debugPrint('Failed to initialize Supabase: $e');
|
|
}
|
|
|
|
runApp(const SageApp());
|
|
}
|
|
|
|
class SageApp extends StatelessWidget {
|
|
const SageApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Sage - Food Inventory Tracker',
|
|
theme: ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
|
|
useMaterial3: true,
|
|
),
|
|
home: const HomePage(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HomePage extends StatelessWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
title: const Text('Sage'),
|
|
),
|
|
body: const Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'Welcome to Sage',
|
|
style: TextStyle(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
SizedBox(height: 16),
|
|
Text(
|
|
'Your collaborative household food inventory tracker',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
SizedBox(height: 32),
|
|
Text(
|
|
'Supabase connection: ✓ Ready',
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.green,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |