-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJwtChecker.dart
30 lines (28 loc) · 990 Bytes
/
JwtChecker.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
import 'package:flutter/material.dart';
import 'package:mobile/screens/login.dart';
import 'package:mobile/screens/signin.dart';
import 'package:mobile/utils/functions.dart';
class JwtChecker extends StatelessWidget {
final Widget screen;
const JwtChecker({Key? key, required this.screen}) : super(key: key);
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: isLogged(),
builder: (context, snapshot) {
if (snapshot.hasData) {
if (snapshot.data == true &&
(screen is! LoginScreen || screen is! SignInScreen)) {
return screen;
} else if (screen is LoginScreen || screen is SignInScreen) {
return screen;
} else {
return const LoginScreen();
}
} else if (snapshot.hasError) {
return Text('error ${snapshot.error}');
}
return const CircularProgressIndicator();
});
}
}