title: FirebaseAnimatedList itemBuilder Error
body: <p>I'm currently going through the Flutter Firebase codelab <a href="https://codelabs.developers.google.com/codelabs/flutter-firebase/#8" rel="nofollow noreferrer">here</a>.</p>
  
  <p>I've followed all the steps, but I'm getting two errors when trying to use the <code>itemBuilder</code> of the <code>FirebaseAnimatedList</code> widget.</p>
  
  <h3>Error 1</h3>
  
  <p>Relates to <code>sort: (a, b) =&gt; b.key.compareTo(a.key)</code>: </p>
  
  <blockquote>
    <p>The function expression type '(dynamic, dynamic) → dynamic' isn't of type '(DataSnapshot, DataSnapshot) → int'. This means its parameter or return type does not match what is expected. Consider changing parameter type(s) or the returned type(s).</p>
  </blockquote>
  
  <p>Do I need to cast the <code>(a,b)</code> to <code>DataSnapshot</code>?</p>
  
  <h3>Error 2</h3>
  
  <p>Relates to the <code>itemBuilder</code> of the <code>FirebaseAnimatedList</code>.</p>
  
  <blockquote>
    <p>The argument type '(BuildContext, DataSnapshot, Animation, int) → dynamic' can't be assigned to the parameter type '(BuildContext, DataSnapshot, Animation) → Widget'.</p>
  </blockquote>
  
  <p>In this case, it seems that the index needs to be passed in, and also that the <code>ChatMessage</code> is returning the wrong type. I'm unsure how to fix these issues though. </p>
  
  <p>Below is the code I have.</p>
  
  <h3>build function of the <code>ChatScreenState</code> class</h3>
  
  <pre><code> @override
    Widget build(BuildContext context) {
      return new Scaffold(
          appBar: AppBar(
            title: Text('friendlychat'),
          ),
          body: Column(
            children: &lt;Widget&gt;[
              Flexible(
                child: FirebaseAnimatedList(
                  query: reference,
                  sort: (a, b) =&gt; b.key.compareTo(a.key),
                  padding: EdgeInsets.all(8.0),
                  reverse: true,
                  itemBuilder: (BuildContext context, DataSnapshot snapshot,
                      Animation&lt;double&gt; animation, int index) {
                    return ChatMessage(snapshot: snapshot, animation: animation);
                  },
                ),
              ),
              Divider(height: 1.0),
              Container(
                decoration: BoxDecoration(color: Theme.of(context).cardColor),
                child: _buildTextComposer(),
              )
            ],
          ));
    }
  </code></pre>
  
  <h3><code>ChatMessage</code> class</h3>
  
  <pre><code>class ChatMessage extends StatelessWidget {
    ChatMessage({this.snapshot, this.animation});
    final DataSnapshot snapshot;
    final Animation animation;
  
    @override
    Widget build(BuildContext context) {
      return SizeTransition(
          sizeFactor: CurvedAnimation(parent: animation, curve: Curves.easeOut),
          axisAlignment: 0.0,
          child: Container(
            margin: EdgeInsets.symmetric(vertical: 10.0),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: &lt;Widget&gt;[
                Container(
                  margin: EdgeInsets.only(right: 16.0),
                  child: CircleAvatar(
                      backgroundImage:
                          NetworkImage(snapshot.value['senderPhotoUrl'])),
                ),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: &lt;Widget&gt;[
                      Text(snapshot.value['senderName'],
                          style: Theme.of(context).textTheme.subhead),
                      Container(
                        margin: EdgeInsets.only(top: 5.0),
                        child: Text(snapshot.value['text']),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ));
    }
  }
  </code></pre>
  
  <h3>updated code for <code>FirebaseAnimatedList</code>:</h3>
  
  <pre><code>FirebaseAnimatedList(
                  query: reference,
                  sort: (DataSnapshot a, DataSnapshot b) =&gt;
                      b.key.compareTo(a.key),
                  padding: EdgeInsets.all(8.0),
                  reverse: true,
                  itemBuilder: (BuildContext context, DataSnapshot snapshot,
                      Animation&lt;double&gt; animation) {
                    return ChatMessage(snapshot: snapshot, animation: animation);
                  },
                ),
  </code></pre>