title: How to cast <dynamic> to List<String>?
body: <p>I have a record class to parse objects coming from Firestore.  A stripped down version of my class looks like:</p>
  
  <pre class="lang-dart prettyprint-override"><code>class BusinessRecord {
    BusinessRecord.fromMap(Map&lt;String, dynamic&gt; map, {this.reference})
        : assert(map['name'] != null),
          name = map['name'] as String,
          categories = map['categories'] as List&lt;String&gt;;
  
    BusinessRecord.fromSnapshot(DocumentSnapshot snapshot)
        : this.fromMap(snapshot.data, reference: snapshot.reference);
  
    final String name;
    final DocumentReference reference;
    final List&lt;String&gt; categories;
  }
  </code></pre>
  
  <p>This compiles fine, but when it runs I get a runtime error:</p>
  
  <p><code>type List&lt;dynamic&gt; is not a subtype of type 'List&lt;String&gt;' in type cast</code></p>
  
  <p>If I just use <code>categories = map['categories'];</code> I get a compile error: <code>The initializer type 'dynamic' can't be assigned to the field type 'List&lt;String&gt;'</code>.</p>
  
  <p><code>categories</code> on my Firestore object is a List of strings. How do I properly cast this?</p>
  
  <p>Edit: Following is what the exception looks like when I use the code that actually compiles:</p>
  
  <p><a href="https://i.stack.imgur.com/WJVLP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WJVLP.png" alt="VSCode Exception"></a></p>