import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'splash_state.dart'; import '../../utils/utils.dart'; class SplashLogic extends GetxController with GetTickerProviderStateMixin { final SplashState state = SplashState(); late AnimationController animationController; late Animation animation; @override void onInit() { super.onInit(); initAnimation(); animationController.forward(); isLoginFn(); } @override void onReady() { debugPrint('onReady'); super.onReady(); } @override void onClose() { animationController.dispose(); super.onClose(); } void initAnimation() { animationController = AnimationController( vsync: this, duration: const Duration(seconds: 1), ); animation = Tween( begin: const Offset(0.0, 1.0), end: Offset.zero, ).animate(CurvedAnimation( parent: animationController, curve: Curves.easeInOut, )); } Future isLoginFn() async { // 倒计时3秒 await Future.delayed(const Duration(seconds: 3), () { final token = StorageUtil().getString("token"); if (!ToolFn.isBlank(token)) { Get.offAllNamed('/home'); } else { Get.offAllNamed('/login'); // Get.toNamed('/login'); } }); } }