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';
2024-04-26 01:14:49 +02:00
import 'package:yokutango_mobile_reader/router.dart';
2022-01-26 00:25:07 +01:00
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({
2024-04-26 01:14:49 +02:00
super.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
}