import 'package:flutter/material.dart'; import 'package:productivity_measure_app/screens/dashboard.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'login.dart'; class Splash extends StatefulWidget { const Splash({super.key}); @override State createState() => _SplashState(); } class _SplashState extends State { @override void initState() { super.initState(); navigateToNextScreen(); } Future navigateToNextScreen() async { SharedPreferences prefs = await SharedPreferences.getInstance(); bool isLoggedIn = prefs.getBool('isLoggedIn') ?? false; await Future.delayed(const Duration(seconds: 3)); // Simulate a delay if (isLoggedIn) { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => Dashboard()), ); } else { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => Login()), ); } } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/images/pro_icon.png', fit: BoxFit.fitWidth, // Adjust width to 80% of screen width width: 250, height: 250, // Adjust the height as needed to match width ), const CircularProgressIndicator(), const SizedBox(height: 20), const Text( 'Loading...', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), ], ), ), ); } }