GithubHelp home page GithubHelp logo

gkpln3 / automatic_animated_list Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 2.0 11 KB

AnimatedList which computes the item deltas each time the underliying list gets updated, and animates the list tiles automatically.

License: Other

Dart 100.00%

automatic_animated_list's People

Contributors

gkpln3 avatar zekfad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

itssidhere ax0elz

automatic_animated_list's Issues

Item builder index

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?

package is rebuilding all the widgets after first one that gets the different data

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.
image
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?

Remove transistion

If I wanna have different remove transitions maybe pass builder argument i.e adding or removing

Incorrect diffing of Key arrays

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.