This repository has been archived by the owner on Sep 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathapp.dart
54 lines (48 loc) · 1.48 KB
/
app.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
51
52
53
54
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:restler/blocs/settings/bloc.dart';
import 'package:restler/i18n.dart';
import 'package:restler/inject.dart';
import 'package:restler/router.dart';
import 'package:restler/theme.dart';
class App extends StatefulWidget {
const App({
Key key,
}) : super(key: key);
@override
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
final SettingsBloc _settingsBloc = kiwi();
@override
void dispose() {
_settingsBloc.close();
super.dispose();
}
@override
Widget build(BuildContext context) {
const i18n = I18n.delegate;
return BlocBuilder<SettingsBloc, SettingsState>(
key: const Key('app'),
cubit: _settingsBloc,
buildWhen: (a, b) => a.darkTheme != b.darkTheme,
builder: (context, state) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: state.darkTheme ? darkTheme() : lightTheme(),
localizationsDelegates: [
i18n,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
],
supportedLocales: i18n.supportedLocales,
localeResolutionCallback:
i18n.resolution(fallback: const Locale('en', 'US')),
onGenerateRoute: generateRoutes,
navigatorKey: navigatorKey,
);
},
);
}
}