forked from thunder-app/thunder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
50 lines (44 loc) · 1.63 KB
/
main.dart
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
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:thunder/core/enums/theme_type.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';
import 'package:thunder/thunder/thunder.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Load up environment variables
await dotenv.load(fileName: ".env");
runApp(const ThunderApp());
}
class ThunderApp extends StatelessWidget {
const ThunderApp({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => ThunderBloc(),
child: BlocBuilder<ThunderBloc, ThunderState>(
builder: (context, state) {
switch (state.status) {
case ThunderStatus.initial:
context.read<ThunderBloc>().add(ThemeChangeEvent(themeType: ThemeType.black));
return const Material(child: Center(child: CircularProgressIndicator()));
case ThunderStatus.loading:
return const Material(child: Center(child: CircularProgressIndicator()));
case ThunderStatus.success:
return MaterialApp(
title: 'Thunder',
// theme: state.theme,
theme: ThemeData.dark(
useMaterial3: true,
),
debugShowCheckedModeBanner: false,
home: const Thunder(),
);
case ThunderStatus.failure:
return const Material(child: Center(child: CircularProgressIndicator()));
}
},
),
);
}
}