gkpln3 / automatic_animated_list Goto Github PK
View Code? Open in Web Editor NEWAnimatedList which computes the item deltas each time the underliying list gets updated, and animates the list tiles automatically.
License: Other
AnimatedList which computes the item deltas each time the underliying list gets updated, and animates the list tiles automatically.
License: Other
It's required to have an index in itemBuilder parameters. Of course, I can access the index of item by list.indexOf(item)
but what if the list contains duplicates?
I have a list that I get from the server,
It is stored in provider.
I assigned the IDs as keys for itembuilder child widgets.
when I update the list from the server it just overwrites the list in provider, no add to or remove from the list is being done.
The automatic animated list updates the widgets as it should but!
the first item that is being removed from the list first fires didUpdateWiget and then initState again.
this happens for each item after the first one that is behind the first removed item.
930 is the one being removed. 933 is first in the list.
When I try with the first item in the list which is before the one that's being removed, the init state is not firing.
Do you know maybe what can be the issue? where can I lookup?
If I wanna have different remove transitions maybe pass builder argument i.e adding or removing
Right now, if you remove multiple elements at the same time, you will get RangeError
.
Locally I fixed it by using diffutil_dart
module for getting array difference:
import 'package:diffutil_dart/diffutil.dart';
// ...
class _AutomaticAnimatedListState<T> extends State<AutomaticAnimatedList<T>> {
// ...
@override
void didUpdateWidget(AutomaticAnimatedList<T> oldWidget) {
super.didUpdateWidget(oldWidget);
final List<Key> oldKeys = oldWidget.items.map((T e) => oldWidget.keyingFunction(e)).toList();
final List<Key> newKeys = widget.items.map((T e) => widget.keyingFunction(e)).toList();
for (final DataDiffUpdate<Key> update in calculateListDiff<Key>(
oldKeys,
newKeys,
detectMoves: false,
).getUpdatesWithData()) {
if (update is DataInsert<Key>) {
_listKey.currentState!.insertItem(
update.position,
duration: widget.insertDuration,
);
} else if (update is DataRemove<Key>) {
_listKey.currentState!.removeItem(
update.position,
(BuildContext context, Animation<double> animation) =>
oldWidget.itemBuilder(context, oldWidget.items[update.position], animation),
duration: widget.removeDuration,
);
}
}
}
// ...
}
// ...
I can make PR if needed.
When all the items on the list get deleted I get a range error. Currently, I handle this by removing the list from the widget tree when there are no items
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.