-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
75 lines (62 loc) · 2.08 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:firebase_core/firebase_core.dart';
import 'backend/firebase/firebase_config.dart';
import 'flutter_flow/flutter_flow_theme.dart';
import 'flutter_flow/flutter_flow_util.dart';
import 'flutter_flow/internationalization.dart';
import 'flutter_flow/nav/nav.dart';
import 'index.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initFirebase();
await FlutterFlowTheme.initialize();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
// This widget is the root of your application.
@override
State<MyApp> createState() => _MyAppState();
static _MyAppState of(BuildContext context) =>
context.findAncestorStateOfType<_MyAppState>()!;
}
class _MyAppState extends State<MyApp> {
Locale? _locale;
ThemeMode _themeMode = FlutterFlowTheme.themeMode;
late AppStateNotifier _appStateNotifier;
late GoRouter _router;
@override
void initState() {
super.initState();
_appStateNotifier = AppStateNotifier();
_router = createRouter(_appStateNotifier);
}
void setLocale(String language) {
setState(() => _locale = createLocale(language));
}
void setThemeMode(ThemeMode mode) => setState(() {
_themeMode = mode;
FlutterFlowTheme.saveThemeMode(mode);
});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Naijafoods',
localizationsDelegates: [
FFLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
locale: _locale,
supportedLocales: const [Locale('en', '')],
theme: ThemeData(brightness: Brightness.light),
darkTheme: ThemeData(brightness: Brightness.dark),
themeMode: _themeMode,
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
);
}
}