connect with backend
This commit is contained in:
@@ -3,10 +3,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/auth_provider.dart';
|
||||
import 'dashboard_screen.dart';
|
||||
import 'main_bottom_nav.dart';
|
||||
import 'welcome_screen.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SplashScreen> createState() => _SplashScreenState();
|
||||
}
|
||||
@@ -19,15 +21,23 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
}
|
||||
|
||||
void _init() async {
|
||||
// small delay to show logo
|
||||
await Future.delayed(const Duration(milliseconds: 900));
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
|
||||
final auth = Provider.of<AuthProvider>(context, listen: false);
|
||||
// ensure provider has loaded prefs
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
|
||||
// 🟢 IMPORTANT → WAIT FOR PREFERENCES TO LOAD
|
||||
await auth.init();
|
||||
|
||||
if (!mounted) return;
|
||||
|
||||
if (auth.isLoggedIn) {
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => const DashboardScreen()));
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (_) => const MainBottomNav()),
|
||||
);
|
||||
} else {
|
||||
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => const WelcomeScreen()));
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (_) => const WelcomeScreen()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,11 +50,23 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
Container(
|
||||
width: size.width * 0.34,
|
||||
height: size.width * 0.34,
|
||||
decoration: BoxDecoration(shape: BoxShape.circle, color: Theme.of(context).primaryColor.withOpacity(0.14)),
|
||||
child: Center(child: Text("K", style: TextStyle(fontSize: 48, fontWeight: FontWeight.bold, color: Theme.of(context).primaryColor))),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Theme.of(context).primaryColor.withOpacity(0.14),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"K",
|
||||
style: TextStyle(
|
||||
fontSize: 48,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).primaryColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
const Text("Kent Logistics", style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600)),
|
||||
const Text("Kent Logistics",
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600)),
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user