-
-
Notifications
You must be signed in to change notification settings - Fork 313
Expand file tree
/
Copy pathmain.dart
More file actions
56 lines (49 loc) · 1.37 KB
/
main.dart
File metadata and controls
56 lines (49 loc) · 1.37 KB
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
import 'package:chatapp/helper/authenticate.dart';
import 'package:chatapp/helper/helperfunctions.dart';
import 'package:chatapp/views/chatrooms.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
// This widget is the root of your application.
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool userIsLoggedIn;
@override
void initState() {
getLoggedInState();
super.initState();
}
getLoggedInState() async {
await HelperFunctions.getUserLoggedInSharedPreference().then((value){
setState(() {
userIsLoggedIn = value;
});
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'FlutterChat',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: Color(0xff145C9E),
scaffoldBackgroundColor: Color(0xff1F1F1F),
accentColor: Color(0xff007EF4),
fontFamily: "OverpassRegular",
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: userIsLoggedIn != null ? userIsLoggedIn ? ChatRoom() : Authenticate()
: Container(
child: Center(
child: Authenticate(),
),
),
);
}
}