title: How do I convert this object so that I can use it in my chat model?
body: <p>I want to loop through the data received from Firebase Realtime Database and for each piece of data, pass it through my <code>ChatData</code> model. However, when I try to pass in <code>snapshot.value</code> it says that <code>The argument type 'Object?' can't be assigned to the parameter type 'Map&lt;dynamic, dynamic&gt;?'.</code> How do I modify <code>snapshot.value</code> so that I can do this?</p>
  <p><strong>The code:</strong></p>
  <pre><code>event.snapshot.children.forEach((snapshot) {
    _dataList.add(snapshot.value);
          
    msg = ChatData.fromJson(snapshot.value);
  });
  </code></pre>
  <p><strong>ChatData model:</strong></p>
  <pre><code>ChatData.fromJson(Map&lt;dynamic, dynamic&gt;? json): //Transform JSON into Message
    uid = json?['uid'] as String,
    text = json?['text'] as String,
    timestamp = DateTime.parse(json?['timestamp'] as String),
    type = json?['type'] as String,
    filterID = json?['filterID'] as String,
    mumbleURL = json?['mumbleURL'] as String;
  </code></pre>
  <p>What I don't understand is that in another version of this code, I simply added each piece of data from the snapshot into a <code>List</code> and then iterated over this list index by index and it worked just fine. Putting into a <code>List</code> first allowed me to pass in each element into <code>ChatData.fromJSON</code> just fine...</p>
  <pre><code>  event.snapshot.children.forEach((snapshot) {
      _dataList.add(snapshot.value);
    });
  
    _dataList.forEach((element) {
      msg = ChatData.fromJson(element); //This works just fine...why?
    });
  </code></pre>