-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.dart
More file actions
59 lines (48 loc) · 1.92 KB
/
main.dart
File metadata and controls
59 lines (48 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:task_management_app/features/auth/presentation/view/auth_gate.dart';
import 'package:task_management_app/features/main/view/screens/main_screen.dart';
import 'package:task_management_app/features/tasks/viewmodel/task_viewmodel.dart';
import 'core/theme/app_theme.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'core/theme/theme_provider.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Tải cấu hình từ file .env
await dotenv.load(fileName: ".env");
String supabaseUrl = dotenv.env['SUPABASE_URL'] ?? '';
String supabaseAnonKey = dotenv.env['SUPABASE_ANON_KEY'] ?? '';
if (supabaseUrl.isEmpty || supabaseAnonKey.isEmpty) {
debugPrint('Error: SUPABASE_URL or SUPABASE_ANON_KEY is missing');
}
await Supabase.initialize(url: supabaseUrl, anonKey: supabaseAnonKey);
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(statusBarColor: Colors.transparent));
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => ThemeProvider()),
ChangeNotifierProvider<TaskViewModel>(
create: (_) => TaskViewModel(),
),
],
child: const TaskApp()));
}
final supabase = Supabase.instance.client;
class TaskApp extends StatelessWidget {
const TaskApp({super.key});
@override
Widget build(BuildContext context) {
final themeProvider = Provider.of<ThemeProvider>(context);
return MaterialApp(
title: 'Task Management App',
themeMode: themeProvider.themeMode,
theme: AppTheme.lightTheme, // Bộ màu sáng ông vừa map xong
darkTheme: AppTheme.darkTheme,
home: const AuthGate(),
debugShowCheckedModeBanner: false,
);
}
}