Updated launch screen
This commit is contained in:
parent
f9e124764f
commit
03d9005c1b
@ -14,7 +14,6 @@ class LaunchScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LaunchScreenState extends State<LaunchScreen> {
|
||||
late Timer _timer;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -50,7 +49,7 @@ class _LaunchScreenState extends State<LaunchScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'TeleMedNet',
|
||||
'TelemedNet',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
StreamBuilder(
|
||||
@ -61,26 +60,7 @@ class _LaunchScreenState extends State<LaunchScreen> {
|
||||
ConnectionState.waiting) {
|
||||
return const CircularProgressIndicator();
|
||||
} else if (snapshot.hasData) {
|
||||
_timer =
|
||||
Timer(const Duration(seconds: 3), () {
|
||||
try {
|
||||
DataService.getProfile()
|
||||
.then((profile) {
|
||||
if (profile == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed(
|
||||
RouteNames.userProfile);
|
||||
} else {
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed(
|
||||
RouteNames.userHome);
|
||||
}
|
||||
});
|
||||
} finally {}
|
||||
_timer.cancel();
|
||||
});
|
||||
_fetchProfileAndNavigate(context);
|
||||
return _buildProceedingWidget(context);
|
||||
} else {
|
||||
return _buildSignInSignUpRow(context);
|
||||
@ -94,6 +74,19 @@ class _LaunchScreenState extends State<LaunchScreen> {
|
||||
)));
|
||||
}
|
||||
|
||||
Future<void> _fetchProfileAndNavigate(BuildContext context) async {
|
||||
var profile = await DataService.getProfile();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
if (profile == null) {
|
||||
Navigator.of(context).pushReplacementNamed(RouteNames.userProfile);
|
||||
} else {
|
||||
Navigator.of(context).pushReplacementNamed(RouteNames.userHome);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildProceedingWidget(BuildContext context) {
|
||||
return const Column(
|
||||
children: [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user