splash.dart 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import 'package:farmer_client/pages/splash/widgets/countdown.dart';
  2. import 'package:get/get.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:get_storage/get_storage.dart';
  6. class SplashScreen extends StatefulWidget {
  7. const SplashScreen({Key? key}) : super(key: key);
  8. @override
  9. State<SplashScreen> createState() => _SplashScreen();
  10. }
  11. class _SplashScreen extends State<SplashScreen> {
  12. GetStorage box = GetStorage();
  13. handleOnFinish() {
  14. bool isLogin = box.hasData('token');
  15. if (isLogin) {
  16. Get.offNamed('/');
  17. } else {
  18. Get.offNamed('/login');
  19. }
  20. }
  21. @override
  22. Widget build(BuildContext context) {
  23. return Scaffold(
  24. body: Container(
  25. decoration: const BoxDecoration(
  26. image: DecorationImage(
  27. image: AssetImage("images/splash.png"),
  28. fit: BoxFit.cover,
  29. alignment: Alignment.topCenter),
  30. ),
  31. child: Stack(
  32. children: [
  33. Positioned(
  34. right: 15.w,
  35. top: 50.h,
  36. child: countdown(3, handleOnFinish),
  37. ),
  38. Positioned(
  39. bottom: 0,
  40. child: Container(
  41. width: 375.w,
  42. height: 60.w,
  43. child: Center(
  44. child: Image.asset(
  45. 'images/logo.png',
  46. width: 218.w,
  47. height: 50.w,
  48. ),
  49. ),
  50. ),
  51. ),
  52. ],
  53. ),
  54. ));
  55. }
  56. }