I want to change the animation speed applied to itemBuilder on AnimatedList in Flutter.

Asked 2 years ago, Updated 2 years ago, 366 views

I use SizeTransition to animate when adding and deleting elements of the list in itemBuilder of AnimatedList on Flutter, but how do I make it faster?

This is the default animation for SizeTransition, how do I change it?

Widget_buildItem(Host host, Animation<double>animation){
  US>return SizeTransition(
    sizeFactor:animation,
    child —ListTile(
      title:Text(host.name),
      training —PopupMenuButton(
        itemBuilder: (context) {
          return [
            PopupMenuItem(child:Text("Edit"), value:host),
            PopupMenuItem(
                child —Text("Delete"),
                onTap:() {
                  AnimatedListRemovedItemBuilder=
                      (context, animation) {
                    return_buildItem(host, animation);
                  };
                  hosts.removeAt(host.own_index);

                  _listKey.currentState!.removeItem(host.own_index, builder,
                      duration —Duration (milliseconds:200);
                }),
          ];
        },
        icon —Icon(Icons.more_vert),
      ),
    ),
  );
}

flutter dart

2022-10-22 09:14

1 Answers

Can I set the insertItem and removeItem parameters in AnimatedListState for a short time?

With the code provided, I think _listKey.currentState corresponds to the object of AnimatedListState.

In the code provided, the deletion is set to 200 ms, but you can set it to 50 ms or something like that.
The code for insertItem is not presented, but I think it can be achieved with a similar implementation.


2022-10-22 09:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.