title: How can I display a QueryDocumentSnapshot from Firebase in a Flutter project? (Flutter, Firebase, Json, Dart)
body: <p>The following is an example QueryDocumentSnapshot called &quot;week&quot; that I get from Firestore with a StreamBuilder.
  I am looking for a way to display this more or less complex data in something like a Card-Widget with the information from each snapshot in my Flutter project.</p>
  <pre><code>{
      &quot;days&quot;:{
          &quot;3&quot;: {
              &quot;activities&quot;: {
                  &quot;1628658343103&quot;: {
                      &quot;query&quot;: &quot;I am watering the plants&quot;, 
                      &quot;finished&quot;: false, 
                      &quot;params&quot;: [
                          {
                              &quot;pronounsDefinite&quot;: &quot;I&quot;
                          }, 
                          {
                              &quot;verbsHelpPresent&quot;: &quot;am&quot;
                          },
                          {
                              &quot;verbsGerund&quot;: &quot;watering&quot;
                          }, 
                          {
                              &quot;articles&quot;: &quot;the&quot;
                          }, 
                          {
                              &quot;nouns&quot;: &quot;plant&quot;
                          }
                      ], 
                      &quot;intent&quot;: &quot;gHomesAndBuildingsGardensAC&quot;, 
                      &quot;duration&quot;: 3
                  }, 
                  &quot;1628673512954&quot;: {
                      &quot;query&quot;: &quot;I am cutting the bushes&quot;, 
                      &quot;finished&quot;: false, 
                      &quot;params&quot;: [
                          {
                              &quot;pronounsDefinite&quot;: &quot;I&quot;
                          }, 
                          {
                              &quot;verbsHelpPresent&quot;: &quot;am&quot;
                          }, 
                          {
                              &quot;verbsGerund&quot;: &quot;cutting&quot;
                          }, 
                          {
                              &quot;articles&quot;: &quot;the&quot;
                          }, 
                          {
                              &quot;nouns&quot;: &quot;bush&quot;
                          }
                      ], 
                      &quot;intent&quot;: &quot;gHomesAndBuildingsGardensAC&quot;, 
                      &quot;duration&quot;: 3
                  }, 
                  &quot;1628673476549&quot;: {
                      &quot;query&quot;: &quot;I work in the garden&quot;, 
                      &quot;finished&quot;: false, 
                      &quot;params&quot;: [
                          {
                              &quot;pronounsDefinite&quot;: &quot;I&quot;
                          }, 
                          {
                              &quot;verbsInfinitiv&quot;: &quot;work&quot;
                          }, 
                          {
                              &quot;prepositions&quot;: &quot;in&quot;
                          }, 
                          {
                              &quot;articles&quot;: &quot;the&quot;
                          }, 
                          {
                              &quot;nouns&quot;: &quot;garden&quot;
                          }], 
                      &quot;intent&quot;: &quot;gHomesAndBuildingsGardensAC&quot;, 
                      &quot;duration&quot;: 4
                  }
              }
          },
          &quot;4&quot;: {
              &quot;activities&quot;: {
                  &quot;1628658343104&quot;: {
                      &quot;query&quot;: &quot;I am watering the plants&quot;, 
                      &quot;finished&quot;: false, 
                      &quot;params&quot;: [
                          {
                              &quot;pronounsDefinite&quot;: &quot;I&quot;
                          }, 
                          {
                              &quot;verbsHelpPresent&quot;: &quot;am&quot;
                          },
                          {
                              &quot;verbsGerund&quot;: &quot;watering&quot;
                          }, 
                          {
                              &quot;articles&quot;: &quot;the&quot;
                          }, 
                          {
                              &quot;nouns&quot;: &quot;plant&quot;
                          }
                      ], 
                      &quot;intent&quot;: &quot;gHomesAndBuildingsGardensAC&quot;, 
                      &quot;duration&quot;: 3
                  }, 
                  &quot;1628673512956&quot;: {
                      &quot;query&quot;: &quot;I am cutting the bushes&quot;, 
                      &quot;finished&quot;: false, 
                      &quot;params&quot;: [
                          {
                              &quot;pronounsDefinite&quot;: &quot;I&quot;
                          }, 
                          {
                              &quot;verbsHelpPresent&quot;: &quot;am&quot;
                          }, 
                          {
                              &quot;verbsGerund&quot;: &quot;cutting&quot;
                          }, 
                          {
                              &quot;articles&quot;: &quot;the&quot;
                          }, 
                          {
                              &quot;nouns&quot;: &quot;bush&quot;
                          }
                      ], 
                      &quot;intent&quot;: &quot;gHomesAndBuildingsGardensAC&quot;, 
                      &quot;duration&quot;: 3
                  }, 
                  &quot;1628673476559&quot;: {
                      &quot;query&quot;: &quot;I work in the garden&quot;, 
                      &quot;finished&quot;: false, 
                      &quot;params&quot;: [
                          {
                              &quot;pronounsDefinite&quot;: &quot;I&quot;
                          }, 
                          {
                              &quot;verbsInfinitiv&quot;: &quot;work&quot;
                          }, 
                          {
                              &quot;prepositions&quot;: &quot;in&quot;
                          }, 
                          {
                              &quot;articles&quot;: &quot;the&quot;
                          }, 
                          {
                              &quot;nouns&quot;: &quot;garden&quot;
                          }], 
                      &quot;intent&quot;: &quot;gHomesAndBuildingsGardensAC&quot;, 
                      &quot;duration&quot;: 3
                  }
              }
          }
      }
  }
  
  </code></pre>
  <p>Here's the problem:
  I have a ListView.builder method which builds a Widget for each snapshot document, like the one above.</p>
  <p>The number-keys in 'activities' are timestamps.
  I can display some text using this:</p>
  <pre><code>...
  Text(
    week['days']['3']['activities']['1628658343103']['query'].toString()
  ), //Which displays: &quot;I am watering the plants&quot;
  
  </code></pre>
  <p>But this way I would have to know every timestamp and call it this way with the exact number which obviously doesn't work.</p>
  <p>How can I use something like 'forEach()' to loop through all the existing entries in activities?</p>
  <p>I also built a model class for this using <a href="https://app.quicktype.io" rel="nofollow noreferrer">https://app.quicktype.io</a>
  but then it throws a FormatException because I try to paste a QueryDocumentSnapshot to the class the moment I try this:</p>
  <pre><code>Widget buildCard(BuildContext context, DocumentSnapshot week) {
      final dataFromWeek = dataFromWeekFromJson(week.toString());
      return new Container(.....); 
  
      //In this Container, all the text from json should be displayed
  }
  
  </code></pre>
  <p>and here is my model-class which I got from the JSON QuickType tool.</p>
  <pre><code>// To parse this JSON data, do
  //
  //     final dataFromWeek = dataFromWeekFromJson(jsonString);
  
  import 'dart:convert';
  
  DataFromWeek dataFromWeekFromJson(String str) =&gt;
      DataFromWeek.fromJson(json.decode(str));
  
  String dataFromWeekToJson(DataFromWeek data) =&gt; json.encode(data.toJson());
  
  class DataFromWeek {
    DataFromWeek({
      this.days,
    });
  
    Map&lt;String, Day&gt; days;
  
    factory DataFromWeek.fromJson(Map&lt;String, dynamic&gt; json) =&gt; DataFromWeek(
          days: Map.from(json[&quot;days&quot;])
              .map((k, v) =&gt; MapEntry&lt;String, Day&gt;(k, Day.fromJson(v))),
        );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
          &quot;days&quot;: Map.from(days)
              .map((k, v) =&gt; MapEntry&lt;String, dynamic&gt;(k, v.toJson())),
        };
  }
  
  class Day {
    Day({
      this.activities,
    });
  
    Map&lt;String, Activity&gt; activities;
  
    factory Day.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Day(
          activities: Map.from(json[&quot;activities&quot;])
              .map((k, v) =&gt; MapEntry&lt;String, Activity&gt;(k, Activity.fromJson(v))),
        );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
          &quot;activities&quot;: Map.from(activities)
              .map((k, v) =&gt; MapEntry&lt;String, dynamic&gt;(k, v.toJson())),
        };
  }
  
  class Activity {
    Activity({
      this.query,
      this.finished,
      this.params,
      this.intent,
      this.duration,
    });
  
    String query;
    bool finished;
    List&lt;Param&gt; params;
    String intent;
    int duration;
  
    factory Activity.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Activity(
          query: json[&quot;query&quot;],
          finished: json[&quot;finished&quot;],
          params: List&lt;Param&gt;.from(json[&quot;params&quot;].map((x) =&gt; Param.fromJson(x))),
          intent: json[&quot;intent&quot;],
          duration: json[&quot;duration&quot;],
        );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
          &quot;query&quot;: query,
          &quot;finished&quot;: finished,
          &quot;params&quot;: List&lt;dynamic&gt;.from(params.map((x) =&gt; x.toJson())),
          &quot;intent&quot;: intent,
          &quot;duration&quot;: duration,
        };
  }
  
  class Param {
    Param({
      this.pronounsDefinite,
      this.verbsHelpPresent,
      this.verbsGerund,
      this.articles,
      this.nouns,
      this.verbsInfinitiv,
      this.prepositions,
    });
  
    String pronounsDefinite;
    String verbsHelpPresent;
    String verbsGerund;
    String articles;
    String nouns;
    String verbsInfinitiv;
    String prepositions;
  
    factory Param.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Param(
          pronounsDefinite:
              json[&quot;pronounsDefinite&quot;] == null ? null : json[&quot;pronounsDefinite&quot;],
          verbsHelpPresent:
              json[&quot;verbsHelpPresent&quot;] == null ? null : json[&quot;verbsHelpPresent&quot;],
          verbsGerund: json[&quot;verbsGerund&quot;] == null ? null : json[&quot;verbsGerund&quot;],
          articles: json[&quot;articles&quot;] == null ? null : json[&quot;articles&quot;],
          nouns: json[&quot;nouns&quot;] == null ? null : json[&quot;nouns&quot;],
          verbsInfinitiv:
              json[&quot;verbsInfinitiv&quot;] == null ? null : json[&quot;verbsInfinitiv&quot;],
          prepositions:
              json[&quot;prepositions&quot;] == null ? null : json[&quot;prepositions&quot;],
        );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
          &quot;pronounsDefinite&quot;: pronounsDefinite == null ? null : pronounsDefinite,
          &quot;verbsHelpPresent&quot;: verbsHelpPresent == null ? null : verbsHelpPresent,
          &quot;verbsGerund&quot;: verbsGerund == null ? null : verbsGerund,
          &quot;articles&quot;: articles == null ? null : articles,
          &quot;nouns&quot;: nouns == null ? null : nouns,
          &quot;verbsInfinitiv&quot;: verbsInfinitiv == null ? null : verbsInfinitiv,
          &quot;prepositions&quot;: prepositions == null ? null : prepositions,
        };
  }
  
  </code></pre>
  <p>I don't actually want to display the 'params' but it would be great if there is some flexibility, which is why I try using a model class to display the snapshot data in a 'Card-Widget'.</p>