42 lines
1.1 KiB
Dart
42 lines
1.1 KiB
Dart
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:tangocard_reader/router.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'service/theme_bloc.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
final prefs = await SharedPreferences.getInstance();
|
|
runApp(MyApp(prefs: prefs));
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
final SharedPreferences prefs;
|
|
|
|
const MyApp({
|
|
Key? key,
|
|
required this.prefs,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) => BlocProvider(
|
|
create: (context) => ThemeBloc(
|
|
prefs: prefs,
|
|
init: (prefs.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,
|
|
),
|
|
),
|
|
);
|
|
}
|