yokutango-mobile-reader/lib/main.dart

42 lines
1.2 KiB
Dart
Raw Normal View History

2022-02-04 15:13:51 +01:00
import 'package:get_it/get_it.dart';
2022-02-04 04:22:35 +01:00
import 'package:shared_preferences/shared_preferences.dart';
2022-01-26 00:25:07 +01:00
import 'package:tangocard_reader/router.dart';
import 'package:flutter/material.dart';
2022-02-04 04:22:35 +01:00
import 'service/theme_bloc.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
2022-02-04 15:13:51 +01:00
GetIt.instance.registerSingleton<SharedPreferences>(
await SharedPreferences.getInstance());
runApp(const MyApp());
2022-02-04 04:22:35 +01:00
}
2022-01-26 00:25:07 +01:00
class MyApp extends StatelessWidget {
2022-02-04 04:22:35 +01:00
const MyApp({
Key? key,
}) : super(key: key);
2022-01-26 00:25:07 +01:00
@override
2022-02-04 04:22:35 +01:00
Widget build(BuildContext context) => BlocProvider(
create: (context) => ThemeBloc(
2022-02-04 15:13:51 +01:00
init:
(GetIt.instance.get<SharedPreferences>().getBool('darkTheme') ??
false)
? Brightness.dark
: Brightness.light),
2022-02-04 04:22:35 +01:00
child: BlocBuilder<ThemeBloc, Brightness>(
builder: (context, state) => MaterialApp(
title: 'Tangocard Reader',
theme: ThemeData(
fontFamily: 'Noto Sans CJK',
primarySwatch: Colors.blue,
brightness: state,
),
initialRoute: '/',
onGenerateRoute: PageRouter.generateRoute,
),
),
);
2022-01-26 00:25:07 +01:00
}