-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.dart
87 lines (69 loc) · 2.06 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
//import 'dart:js';
//import 'dart:js';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:sozonew/ArticleList.dart';
import 'package:sozonew/Map.dart';
import 'package:sozonew/loginpage.dart';
import 'home_page.dart';
import 'user_profile.dart';
void main() {
runApp(
MaterialApp(
initialRoute: '/land',
debugShowCheckedModeBanner: false,
routes: {
'/land':(context)=>landingclass(),
'/':(context)=>loginpage(),
'/first':(context)=>Homepage(),
'/second':(context)=>UserProfile(),
'/third':(context)=>ArticleList(title: "Safety Tips"),
'/map':(context)=>MapPage(),
},
),
);
}
class landingclass extends StatelessWidget {
final Future<FirebaseApp> _initialization = Firebase.initializeApp();
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: _initialization,
builder: (context,snapshot){
if(snapshot.hasError){
return Scaffold(
body: Center(
child:Text("Error :${snapshot.error}"),
)
);
}
if(snapshot.connectionState == ConnectionState.done){
return StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context,snapshot){
if(snapshot.connectionState == ConnectionState.active){
User user = snapshot.data;
if(user == null){
return loginpage();
}
else{
return Homepage();
}}
return Scaffold(
body:Center(
child: Text("Checking Authentication...."),
)
);
}
);
}
return Scaffold(
body:Center(
child: Text("Connecting to the app...."),
)
);
}
);
}
}