import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:trans_lark/core/router/router.dart'; class SplashController extends GetxController with GetTickerProviderStateMixin { var processValue = 0.0.obs; late AnimationController _controller; late Animation _animation; @override void onInit() { super.onInit(); _controller = AnimationController( duration: const Duration(seconds: 10), vsync: this, ); // 创建 Tween 并绑定到 AnimationController _animation = Tween(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); } }