update
This commit is contained in:
parent
b45cf8bd73
commit
941e9eaa5b
8 changed files with 91 additions and 19 deletions
|
|
@ -9,16 +9,38 @@ import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
|
|||
import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/title_widget.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class MainPage extends StatelessWidget {
|
||||
class MainPage extends StatefulWidget {
|
||||
const MainPage({super.key});
|
||||
|
||||
@override
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> {
|
||||
void _checkLogged() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
bool userStatus = prefs.containsKey('user');
|
||||
if (!userStatus) {
|
||||
// ignore: use_build_context_synchronously
|
||||
context.go('/');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_checkLogged();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authService = AuthService();
|
||||
|
||||
void signOut() async {
|
||||
await authService.signOut().then((_) => {context.push('/'), showNotification(context, 'Logged Out', true)});
|
||||
// ignore: use_build_context_synchronously
|
||||
await authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
|
||||
}
|
||||
|
||||
return PopScope(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue