From 1eca96006937ef86dfd5fd39f58e748d993c7e80 Mon Sep 17 00:00:00 2001 From: Sun Date: Sun, 25 Apr 2021 22:10:48 +0800 Subject: [PATCH] change processbar move gently --- lib/pages/home.dart | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/pages/home.dart b/lib/pages/home.dart index 71cf017..ff3ab78 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -96,32 +96,32 @@ class HomeList extends StatefulWidget { _HomeListState createState() => _HomeListState(); } -class _HomeListState extends State { +class _HomeListState extends State with SingleTickerProviderStateMixin { bool isShowHome = true; bool isShowFriends = false; bool isShowGroups = false; bool isShowFiles = false; bool isProcess = true; - double processNum = 0.0; - Timer timer; + AnimationController controller; @override void initState() { - super.initState(); - timer = Timer.periodic(Duration(seconds: 1), (Timer _t) { - processNum += 0.1; - if (processNum > 1.0) { - isProcess = false; - timer?.cancel(); - } - setState(() {}); + controller = AnimationController( + vsync: this, duration: const Duration(seconds: 5) + )..addListener(() { + if (controller.value == 1.0) { + isProcess = false; + } + setState(() {}); }); + controller.forward(); + super.initState(); } @override void dispose() { - timer?.cancel(); + controller.dispose(); super.dispose(); } @@ -319,7 +319,7 @@ class _HomeListState extends State { ? LinearProgressIndicator( backgroundColor: Color(0x40ADB0BB), valueColor: AlwaysStoppedAnimation(color.primary), - value: processNum, + value: controller.value, ) : const Divider(height: 1.0, color: Color(0x40ADB0BB)), const SizedBox(height: 5.0),