title: How do I set up a nested field in a Cloud Firestore database using JSONserializable in flutter
body: <p>I have set up two of the Collections in My Cloud Firestore database in Flutter using JSONSerializable. This is shown below</p>
  <p><strong>models.dart</strong></p>
  <pre><code>import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:json_annotation/json_annotation.dart';
  part 'models.g.dart';
  
  enum RecordType {
    weightAndReps,
    repsOnly,
    time,
    timeAndWeight,
    distance,
  }
  
  @JsonSerializable()
  class User {
    final String id;
    final String username;
    final String name;
    final String email;
    final String password;
    final String image;
    final bool isAdmin;
  
    User(
        {this.id = '',
        this.username = '',
        this.name = '',
        this.email = '',
        this.password = '',
        this.image = '',
        this.isAdmin = false});
  
    factory User.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$UserFromJson(json);
    Map&lt;String, dynamic&gt; toJson() =&gt; _$UserToJson(this);
  }
  
  @JsonSerializable()
  class Exercise {
    final String id;
    final String name;
    final String description;
    final String image;
    final RecordType recordType;
    final String primaryMuscleGroup;
    final List&lt;String&gt; secondaryMuscleGroup;
  
    Exercise(
        {this.id = '',
        this.name = '',
        this.description = '',
        this.image = '',
        this.recordType = RecordType.weightAndReps,
        this.primaryMuscleGroup = '',
        this.secondaryMuscleGroup = const []});
  
    factory Exercise.fromJson(Map&lt;String, dynamic&gt; json) =&gt;
        _$ExerciseFromJson(json);
    Map&lt;String, dynamic&gt; toJson() =&gt; _$ExerciseToJson(this);
  }
  </code></pre>
  <p>However, I am having problems with the Workout Collection due to the number of nested fields and the fact that the Map datatypes in use have more than two elements which I cannot utilise in dart. I am fairly new to this and cannot find much online on how to do this. The collection in question is shown in the image below.</p>
  <p><a href="https://i.stack.imgur.com/rAbQA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rAbQA.png" alt="enter image description here" /></a></p>
  <p>Any help would be greatly appreciated</p>