VOOZH about

URL: https://www.geeksforgeeks.org/flutter/flutter-animate-items-in-list-using-animatedlist/

⇱ Flutter - Animate Items in List Using AnimatedList - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Flutter - Animate Items in List Using AnimatedList

Last Updated : 23 Jul, 2025

The AnimatedList widget in Flutter is used to create a list that automatically animates changes to its items. It's particularly useful when you want to add or remove items from a list with smooth animations. In this article, we are going to see how the list is animated when an item is deleted or added to the list. In this article, we are going to implement the AnimatedList widget. A sample video is given below to get an idea about what we are going to do in this article.

Basic Syntax of AnimatedList Widget

AnimatedList(
key: GlobalKey<AnimatedListState>(), // A unique key to identify the list
initialItemCount: itemCount, // The initial number of items in the list
itemBuilder: (BuildContext context, int index, Animation<double> animation) {
// The builder function for creating list items
return YourListItemWidget(item: yourDataList[index], animation: animation);
},
)

Required Tools

To build this app, you need the following items installed on your machine:

  • Visual Studio Code / Android Studio
  • Android Emulator / iOS Simulator / Physical Device device.
  • Flutter Installed
  • Flutter plugin for VS Code / Android Studio.

Step By Step Implementation

Step 1: Create a New Project in Android Studio

To set up Flutter Development on Android Studio please refer to Android Studio Setup for Flutter Development, and then create a new project in Android Studio please refer to Creating a Simple Application in Flutter.

Step 2: Import the Package

First of all import material.dart file.

import 'package:flutter/material.dart';

Step 3: Execute the main Method

Here the execution of our app starts.

Step 4: Create MyApp Class

In this class we are going to implement the MaterialApp , here we are also set the Theme of our App.

Step 5: Create MyAnimatedList Class

In this class we are going to Implement the AnimatedList widget that help to Animated the list when an item is added or removed. This class contains 3 methods :

  • _addItem method is used to add a new item to the list.
  • _removeItem method is used to remove an item from the list.
  • buildItem is a helper method that builds each item in the list. It uses SizeTransition for the animation effect.

Comments are added for better understanding.

AnimatedList(
key: _listKey,
initialItemCount: _items.length,
itemBuilder: (context, index, animation) {
return buildItem(_items[index], animation); // Build each list item
},
),

Here is the full Code of main.dart file

Output:

Comment

Explore