title: Fetching data from Firestore and map it into a provider object
body: <p>I have a problem combining Firestore with the Provider (State Management) in Flutter. 
  My problem is mainly to map the data retrieved from firestore on my class. -> Deserializing Firebase Data to a Dart Class</p>
  
  <p>I am able to retrieve the data from Firestore and print it into the console.</p>
  
  <p>If I want to use json.decode I always get "type xx ' is not a subtype of type 'Map'" which is also mentioned here <a href="https://github.com/flutter/flutter/issues/17417" rel="nofollow noreferrer">https://github.com/flutter/flutter/issues/17417</a></p>
  
  <p>My Run Class</p>
  
  <pre><code>import 'package:flutter/foundation.dart';
  import 'package:cloud_firestore/cloud_firestore.dart';
  
  enum Complexity { simple, challenging, hard }
  
  class Run with ChangeNotifier {
    final String id;
    final String title;
    final List&lt;String&gt; workouts;
    final String imageUrl;
    final List&lt;String&gt; intervals;
    final List&lt;String&gt; steps;
    final int duration;
    Complexity complexity;
    final bool isRecovery;
    bool isBeginner;
  
    Run(
        {@required this.id,
        @required this.title,
        @required this.workouts,
        @required this.imageUrl,
        @required this.intervals,
        @required this.steps,
        this.duration,
        this.complexity,
        this.isRecovery,
        this.isBeginner});
  
    factory Run.fromDocument(DocumentSnapshot doc) {
      return Run(
          id: doc.documentID,
          title: doc['title'] ?? '',
          workouts: doc['workouts'] ?? 0,
          imageUrl: doc['imageUrl'] ?? '',
          intervals: doc['intervals'] ?? 0,
          steps: doc['steps'] ?? 0);
    }
  </code></pre>
  
  <p>My Runs class which should fetch the data</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:xxx/providers/run.dart';
  import 'package:cloud_firestore/cloud_firestore.dart';
  import 'dart:convert';
  
  final runsRef = Firestore.instance.collection('runs');
  
  class Runs with ChangeNotifier {
    List&lt;Run&gt; _items = [];
  
    fetchRuns() async {
      DocumentSnapshot snapshot =
          await runsRef.getDocuments().then((QuerySnapshot snapshot) {
        snapshot.documents.forEach((DocumentSnapshot doc) {
          print(doc.data);
        });
      });
    }
  </code></pre>
  
  <ol>
  <li>I want to call the function fetchRuns to get all documents in the collection</li>
  <li>I want to map this retrieved data to my Class </li>
  <li>I want to use this class as a Provider to provide state/data to different screens</li>
  </ol>
  
  <p>I am stuck at step 2 and can't really solve that.</p>