title: How to use AnimatedList Widget in Flutter
body: <p>I saw this <a href="https://youtu.be/ZtfItHwFlZ8" rel="noreferrer">video on youtube</a></p>
  
  <p>and I'm trying to implement an animated list,</p>
  
  <p>but I'm not really familiar with animations.</p>
  
  <p>What I'm supposed to insert as </p>
  
  <blockquote>
    <p>position: animation.drive(),</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>removeItem(_index,(context,animation)=>  /// what I'm supposed to do
    here
        ),);</p>
  </blockquote>
  
  <p>here's the code (just few changes from the "starting app")</p>
  
  <pre><code>      class MyHomePage extends StatefulWidget {
    MyHomePage({Key key, this.title}) : super(key: key);
    final String title;
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; with SingleTickerProviderStateMixin {
    List&lt;int&gt; _list = [];
    final GlobalKey&lt;AnimatedListState&gt; _listKey = GlobalKey&lt;AnimatedListState&gt;();
  
  
    void _addItem() {
      final int _index = _list.length;
      _list.insert(_index,_index);
      _listKey.currentState.insertItem(_index);
    }
  
    void _removeItem() {
      final int _index = _list.length-1;
      _listKey.currentState.removeItem(_index,(context,animation)=&gt;  /// what I'm supposed to do here
      ),);
    }
  
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
  
          child: AnimatedList(
            key: _listKey,
            initialItemCount: 0,
            itemBuilder: (BuildContext context, int index, Animation animation) {
              return SlideTransition(
                position: animation.drive(
                    /// what I'm supposed to do here
             ),
                child: Card(child: Text(_list[index].toString()),));
            },),
        ),
        floatingActionButton: Column(children: &lt;Widget&gt;[
           FloatingActionButton(
            onPressed:()=&gt; _addItem(),
            tooltip: 'Increment',
            child: Icon(Icons.add),),
          FloatingActionButton(
            onPressed: ()=&gt;_removeItem(),
            tooltip: 'Decrement',
            child: Icon(Icons.remove),),
        ],), 
      );
    }
  }
  </code></pre>
  
  <p>looking around for tutorial on SliderTransition I see this:</p>
  
  <pre><code>SlideTransition(
                  position: Tween&lt;Offset&gt;(
                    begin: const Offset(-1, 0),
                    end: Offset.zero,
                  ).animate(animation),
  </code></pre>
  
  <p>while I have this:</p>
  
  <pre><code> SlideTransition(
                    position: animation.drive(
                        // what i supposed to go here ??
                    ),
  </code></pre>
  
  <p>can anybody help?</p>
  
  <p>is it only this missing piece or I'm missing something else?</p>
  
  <p>thank you in advance</p>
  
  <p>[edit: the <a href="https://flutter.dev/docs/catalog/samples/animated-list" rel="noreferrer">AnimatedList page</a>  shows the message </p>
  
  <blockquote>
    <p>This page is deprecated and its content may be out of date.</p>
  </blockquote>
  
  <p>in fact doesn't seems to use this widget at all]</p>