64 lines
1.3 KiB
Dart
64 lines
1.3 KiB
Dart
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<Offset> 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<Offset>(
|
|
begin: const Offset(0.0, 1.0),
|
|
end: Offset.zero,
|
|
).animate(CurvedAnimation(
|
|
parent: animationController,
|
|
curve: Curves.easeInOut,
|
|
));
|
|
}
|
|
|
|
Future<void> isLoginFn() async {
|
|
// 倒计时3秒
|
|
await Future.delayed(const Duration(seconds: 3), () {
|
|
final token = StorageUtil().getString("token");
|
|
if (!ToolFn.isBlank(token)) {
|
|
Get.offAllNamed('/tab');
|
|
} else {
|
|
Get.offAllNamed('/login');
|
|
}
|
|
});
|
|
}
|
|
}
|