47 lines
1.0 KiB
Dart
47 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:trans_lark/router/router.dart';
|
|
|
|
class SplashController extends GetxController with GetTickerProviderStateMixin {
|
|
var processValue = 0.0.obs;
|
|
late AnimationController _controller;
|
|
late Animation<double> _animation;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
_controller = AnimationController(
|
|
duration: const Duration(seconds: 10),
|
|
vsync: this,
|
|
);
|
|
|
|
// 创建 Tween 并绑定到 AnimationController
|
|
_animation = Tween<double>(begin: 0, end: 1).animate(_controller)
|
|
..addListener(() {
|
|
processValue.value = _animation.value;
|
|
if (processValue.value >= 1) {
|
|
_openInitial();
|
|
}
|
|
});
|
|
|
|
// 启动动画
|
|
_controller.forward();
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
_controller.dispose();
|
|
super.onClose();
|
|
}
|
|
|
|
/// 打开首个页面
|
|
void _openInitial() {
|
|
Get.offNamed(GetRouter.home);
|
|
}
|
|
}
|