From 97637e5baaa2875f97bf79aac475c5301c4c7f3e Mon Sep 17 00:00:00 2001 From: Dani B Date: Wed, 28 Jan 2026 08:40:26 -0500 Subject: [PATCH] feat(01-01): Initialize Supabase in main.dart - 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 --- lib/main.dart | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 lib/main.dart diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..195f122 --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,86 @@ +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, + ), + ), + ], + ), + ), + ); + } +} \ No newline at end of file