-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathmain.dart
53 lines (48 loc) · 1.18 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
import 'package:blogapp/Blog/addBlog.dart';
import 'package:blogapp/Pages/HomePage.dart';
import 'package:blogapp/Profile/MainProfile.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'Pages/LoadingPage.dart';
import 'Pages/WelcomePage.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Widget page = LoadingPage();
final storage = FlutterSecureStorage();
@override
void initState() {
// TODO: implement initState
super.initState();
checkLogin();
}
void checkLogin() async {
String token = await storage.read(key: "token");
if (token != null) {
setState(() {
page = HomePage();
});
} else {
setState(() {
page = WelcomePage();
});
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
textTheme: GoogleFonts.openSansTextTheme(
Theme.of(context).textTheme,
),
),
home: page,
);
}
}