-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// ignore_for_file: file_names, use_build_context_synchronously | ||
|
||
import 'dart:developer'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:trashsure/pages/LandingPage.dart'; | ||
import 'package:trashsure/pages/user/UserPage.dart'; | ||
import 'package:trashsure/utils/auth.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class SplashPage extends StatefulWidget { | ||
const SplashPage({super.key}); | ||
|
||
@override | ||
State<SplashPage> createState() => _SplashPageState(); | ||
} | ||
|
||
class _SplashPageState extends State<SplashPage> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
_checkLoggedInAndNavigate(); | ||
} | ||
|
||
void _checkLoggedInAndNavigate() async { | ||
final request = context.read<CookieRequest>(); | ||
await request.init(); | ||
log("init ${request.cookies}"); | ||
if (request.loggedIn) { | ||
Navigator.pushReplacement( | ||
context, | ||
MaterialPageRoute(builder: (context) => const UserPage(idx: 0)), | ||
); | ||
} else { | ||
Navigator.pushReplacement( | ||
context, | ||
MaterialPageRoute(builder: (context) => const LandingPage()), | ||
); | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Center( | ||
child: CircularProgressIndicator(), // Display a loading indicator | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters