42 lines
1.2 KiB
Dart
42 lines
1.2 KiB
Dart
import 'package:get_it/get_it.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:yokutango_mobile_reader/router.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'service/theme_bloc.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
GetIt.instance.registerSingleton<SharedPreferences>(
|
|
await SharedPreferences.getInstance());
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => BlocProvider(
|
|
create: (context) => ThemeBloc(
|
|
init:
|
|
(GetIt.instance.get<SharedPreferences>().getBool('darkTheme') ??
|
|
false)
|
|
? Brightness.dark
|
|
: Brightness.light),
|
|
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,
|
|
),
|
|
),
|
|
);
|
|
}
|