import 'dart:async'; import 'package:cheminova/screens/authentication/login_screen.dart'; import 'package:cheminova/screens/home_screen.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SplashScreen extends StatefulWidget { const SplashScreen({super.key}); @override State createState() => _SplashScreenState(); } class _SplashScreenState extends State { @override void initState() { Timer(const Duration(seconds: 3), () { checkLogin(); }); super.initState(); } checkLogin() async { SharedPreferences prefs = await SharedPreferences.getInstance(); String? token = prefs.getString('token'); if (token != null) { Get.offAll(() => const HomeScreen()); } else { Get.offAll(() => const LoginScreen()); } } @override Widget build(BuildContext context) { return Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( margin: EdgeInsets.fromLTRB( Get.width * 0.07, 0, Get.width * 0.07, Get.height * 0.01), child: Container( decoration: const BoxDecoration( image: DecorationImage( fit: BoxFit.fill, image: AssetImage( 'assets/images/px_cheminova_svg.png', ), ), ), child: SizedBox( width: Get.width * 0.8, height: Get.height * 0.05, ), ), ), Container( margin: EdgeInsets.only(bottom: Get.height * 0.1), child: Text( 'HELPING YOU GROW', style: GoogleFonts.getFont( 'Roboto', fontWeight: FontWeight.w500, fontSize: Get.textScaleFactor * 20, height: 1.3, color: const Color(0xFF000000), ), ), ), Container( margin: EdgeInsets.only(bottom: Get.height * 0.15), child: Container( decoration: const BoxDecoration( image: DecorationImage( fit: BoxFit.cover, image: AssetImage( 'assets/images/plant_png_barter_new_sales_ims_barter_trade_exchange_network_33.png', ), ), ), child: SizedBox( width: Get.width * 0.8, height: Get.height * 0.4, ), ), ), Text( 'Powered By', style: GoogleFonts.getFont( 'Roboto', fontWeight: FontWeight.w500, fontSize: Get.textScaleFactor * 12, color: const Color(0xFF000000), ), ), SizedBox(height: Get.height * 0.005), // Reduced spacing Text( 'codeology.solutions', style: GoogleFonts.getFont( 'Roboto', fontWeight: FontWeight.w500, fontSize: Get.textScaleFactor * 14, color: const Color(0xFF000000), ), ), ], ), ); } }