-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.dart
107 lines (89 loc) · 3.04 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:praso/home_screen.dart';
import 'package:praso/web_view_redirect.dart';
import 'package:provider/provider.dart';
Future<void> messageHandler(RemoteMessage message) async {
}
ConnectivityResult? connectivityResult;
ConnectionState? connectionState;
double screenWidth = 0.0;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(messageHandler);
await FlutterDownloader.initialize(
debug: true // optional: set false to disable printing logs to console
);
runApp( MultiProvider(
providers: [
ChangeNotifierProvider<PrasoNotifyProvider>(create: (context) => PrasoNotifyProvider(),)
],
child: const MaterialApp(
debugShowCheckedModeBanner: false,
home: MyApp(),
title: 'Praso App',
),
));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late FirebaseMessaging messaging;
Future<void> initializeMyFirebaseApp() async {
await Firebase.initializeApp();
}
@override
void initState() {
messaging = FirebaseMessaging.instance;
super.initState();
}
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
statusBarColor: Color(0xFF487CEA),
));
screenWidth = MediaQuery.of(context).size.width;
Future.delayed(const Duration(seconds: 1), () async {
connectivityResult = await Connectivity().checkConnectivity();
switch (connectivityResult!) {
case ConnectivityResult.mobile:
case ConnectivityResult.wifi:
{
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const WebViewPage(),));
break;
}
case ConnectivityResult.none:
{
Navigator.push(context, MaterialPageRoute(builder: (context) => const ErrorScreen(),));
break;
}
case ConnectivityResult.ethernet:
break;
}
});
return Scaffold(
backgroundColor: const Color(0xFF487CEA),
body: Center(
child: Container(
height: 200,
width: screenWidth * 0.80,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
image: const DecorationImage(
image: AssetImage('assets/images/praso_splash_icon.png'),
)
),
),
),
);
}
}