summaryrefslogtreecommitdiff
path: root/lib/main.dart
blob: 0b10f9b044873c6497e1ddb9d77bb53fc5200aaf (plain)
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
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:pmsna1/providers/flags_provider.dart';
import 'package:pmsna1/providers/theme_provider.dart';
import 'package:pmsna1/routes.dart';
import 'package:pmsna1/settings/themes.dart';
import 'package:provider/provider.dart';

void main(List<String> args) async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  return runApp(const MainContent());
}

class MainContent extends StatefulWidget {
  const MainContent({super.key});

  @override
  State<MainContent> createState() => _MainContentState();
}

class _MainContentState extends State<MainContent> {
  int contador = 0;

  @override
  void initState() {
    super.initState();
    contador = 0;
  }

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => ThemeProvider()),
        ChangeNotifierProvider(create: (_) => FlagsProvider()),
      ],
      child: const PMSNA1(),
    );
  }
}

class PMSNA1 extends StatelessWidget {
  const PMSNA1({super.key});

  @override
  Widget build(BuildContext context) {
    final ThemeProvider provider = context.watch<ThemeProvider>();
    final ThemeData? theme = provider.theme;
    provider.syncFromPrefs();
    return MaterialApp(
      theme: theme ?? ThemeSettings.lightTheme,
      darkTheme: theme ?? ThemeSettings.darkTheme,
      themeMode: ThemeMode.system,
      routes: getApplicationRoutes(),
      initialRoute: '/login',
    );
  }
}