Skip to content

Commit

Permalink
[auto_animated] Forvard animation on items count changed in AutoAnima…
Browse files Browse the repository at this point in the history
…tedList
  • Loading branch information
SergeShkurko committed Oct 31, 2019
1 parent 3b6362c commit add23dc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/auto_animated/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.3

* Forvard animation on items count changed in `AutoAnimatedList`

## 1.2.2

* Fixed dispose in `AutoAnimatedIconButton`
Expand Down
2 changes: 1 addition & 1 deletion packages/auto_animated/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.2.2"
version: "1.2.3"
boolean_selector:
dependency: transitive
description:
Expand Down
13 changes: 13 additions & 0 deletions packages/auto_animated/lib/src/auto_animated_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ class AutoAnimatedListState extends State<AutoAnimatedList>
@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) {
Expand All @@ -342,6 +347,14 @@ class AutoAnimatedListState extends State<AutoAnimatedList>
});
}

@override
void didUpdateWidget(AutoAnimatedList oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.itemCount != widget.itemCount) {
init();
}
}

@override
void dispose() {
_timer?.cancel();
Expand Down
2 changes: 1 addition & 1 deletion packages/auto_animated/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <sergeshkurko@outlook.com>
homepage: https://github.com/rbcprolabs/flutter_plugins/tree/master/packages/auto_animated

Expand Down

0 comments on commit add23dc

Please sign in to comment.