67 lines
1.9 KiB
Dart
67 lines
1.9 KiB
Dart
import 'dart:io';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
|
import 'app/router/app_router.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// Load environment variables from .env
|
|
await dotenv.load(fileName: '.env');
|
|
|
|
final supabaseUrl = dotenv.env['SUPABASE_URL'] ?? '';
|
|
final supabaseKey = dotenv.env['SUPABASE_PUBLISHABLE_KEY'] ??
|
|
dotenv.env['SUPABASE_ANON_KEY'] ??
|
|
'';
|
|
|
|
if (supabaseUrl.isNotEmpty && supabaseKey.isNotEmpty) {
|
|
await Supabase.initialize(
|
|
url: supabaseUrl,
|
|
publishableKey: supabaseKey,
|
|
);
|
|
} else {
|
|
debugPrint(
|
|
'WARNING: SUPABASE_URL or SUPABASE_PUBLISHABLE_KEY missing in .env. Supabase client uninitialized.',
|
|
);
|
|
}
|
|
|
|
runApp(const ProviderScope(child: GLP1CompanionApp()));
|
|
}
|
|
|
|
class GLP1CompanionApp extends ConsumerWidget {
|
|
const GLP1CompanionApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final router = ref.watch(routerProvider);
|
|
final isApple = !kIsWeb && (Platform.isIOS || Platform.isMacOS);
|
|
|
|
if (isApple) {
|
|
return CupertinoApp.router(
|
|
title: 'GLP-1 Companion',
|
|
routerConfig: router,
|
|
theme: const CupertinoThemeData(
|
|
brightness: Brightness.light,
|
|
primaryColor: CupertinoColors.activeGreen,
|
|
),
|
|
debugShowCheckedModeBanner: false,
|
|
);
|
|
}
|
|
|
|
return MaterialApp.router(
|
|
title: 'GLP-1 Companion',
|
|
routerConfig: router,
|
|
theme: ThemeData(
|
|
useMaterial3: true,
|
|
colorSchemeSeed: Colors.teal,
|
|
brightness: Brightness.light,
|
|
),
|
|
debugShowCheckedModeBanner: false,
|
|
);
|
|
}
|
|
}
|