From add23dc3e37b9d8b54a71f806dd272d23c648865 Mon Sep 17 00:00:00 2001 From: Serge Shkurko Date: Mon, 28 Oct 2019 15:16:39 +0500 Subject: [PATCH] [auto_animated] Forvard animation on items count changed in AutoAnimatedList --- packages/auto_animated/CHANGELOG.md | 4 ++++ packages/auto_animated/example/pubspec.lock | 2 +- .../auto_animated/lib/src/auto_animated_list.dart | 13 +++++++++++++ packages/auto_animated/pubspec.yaml | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/auto_animated/CHANGELOG.md b/packages/auto_animated/CHANGELOG.md index bf68f12c..f87dce17 100644 --- a/packages/auto_animated/CHANGELOG.md +++ b/packages/auto_animated/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.3 + +* Forvard animation on items count changed in `AutoAnimatedList` + ## 1.2.2 * Fixed dispose in `AutoAnimatedIconButton` diff --git a/packages/auto_animated/example/pubspec.lock b/packages/auto_animated/example/pubspec.lock index e38ff744..d522dbb9 100644 --- a/packages/auto_animated/example/pubspec.lock +++ b/packages/auto_animated/example/pubspec.lock @@ -14,7 +14,7 @@ packages: path: ".." relative: true source: path - version: "1.2.2" + version: "1.2.3" boolean_selector: dependency: transitive description: diff --git a/packages/auto_animated/lib/src/auto_animated_list.dart b/packages/auto_animated/lib/src/auto_animated_list.dart index 0f0b6bab..eb048f65 100644 --- a/packages/auto_animated/lib/src/auto_animated_list.dart +++ b/packages/auto_animated/lib/src/auto_animated_list.dart @@ -329,6 +329,11 @@ class AutoAnimatedListState extends State @override void initState() { super.initState(); + init(); + } + + void init() { + _itemsCount = 0; Future.delayed(widget.delay, () { _timer = Timer.periodic(widget.showItemInterval, (Timer timer) { if (_itemsCount == widget.itemCount || !mounted) { @@ -342,6 +347,14 @@ class AutoAnimatedListState extends State }); } + @override + void didUpdateWidget(AutoAnimatedList oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.itemCount != widget.itemCount) { + init(); + } + } + @override void dispose() { _timer?.cancel(); diff --git a/packages/auto_animated/pubspec.yaml b/packages/auto_animated/pubspec.yaml index dfbd64a2..7ed236f9 100644 --- a/packages/auto_animated/pubspec.yaml +++ b/packages/auto_animated/pubspec.yaml @@ -1,6 +1,6 @@ name: auto_animated description: Widgets starting auto play animation when mounted. It is already possible to animate the list and icons. -version: 1.2.2 +version: 1.2.3 author: Serge Shkurko homepage: https://github.com/rbcprolabs/flutter_plugins/tree/master/packages/auto_animated