title: Writing and Reading JSON files locally in Flutter Doesn't include Quotes
body: <p>I am writing an object to a JSON file locally. When I try and read it, I receive this error:</p>
  <pre><code>E/flutter ( 7621): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FormatException: Unexpected character (at character 2)
  E/flutter ( 7621): {players: [{id: Nebula, setCount: 0 - 0, characters: {char1: ice_climbers, char2: captain_falcon}, notes: }]}
  E/flutter ( 7621):  ^
  </code></pre>
  <p>I understand that the reason I'm getting this error is because that <em>player</em> is not between quotes. i.e. &quot;player&quot;. I do not know how to write the object as a JSON with the quotes included.</p>
  <p>This code was generated by the JsonSerializableGenerator <br>
  PlayerList.toJson:</p>
  <pre><code>PlayerList _$PlayerListFromJson(Map&lt;String, dynamic&gt; json) {
    return PlayerList(
      (json['players'] as List)
          ?.map((e) =&gt;
              e == null ? null : Player.fromJson(e as Map&lt;String, dynamic&gt;))
          ?.toList(),
    );
  }
  
  Map&lt;String, dynamic&gt; _$PlayerListToJson(PlayerList instance) =&gt;
      &lt;String, dynamic&gt;{
        'players': instance.players?.map((e) =&gt; e?.toJson())?.toList(),
      };
  </code></pre>
  <p>This is how I read and write the file:</p>
  <pre><code>Future&lt;String&gt; get _localPath async {
    final directory = await getApplicationDocumentsDirectory();
    return directory.path;
  }
  
  Future&lt;File&gt; get _localFile async {
    final path = await _localPath;
    return File('$path/playerData.json');
  }
  
  Future&lt;File&gt; writePlayerData(PlayerList playerList) async {
    final file = await _localFile;
    return file.writeAsString(playerList.toJson().toString());
  }
  
  Future&lt;PlayerList&gt; readPlayerData () async {
    try {
      final file = await _localFile;
      String contents = await file.readAsString();
      final jsonResponse = jsonDecode(contents);
      PlayerList playerList = PlayerList.fromJson(jsonResponse);
      return playerList;
    } catch (e) {
      print(e);
      return getPlayerList(); //just loads a placeholder json in the assets folder;
    }
  }
  </code></pre>
  <p>What I want the JSON to be formatted as:</p>
  <pre><code>{
    &quot;players&quot;: [
      {
        &quot;id&quot;: &quot;Filler Character&quot;,
        &quot;setCount&quot;: &quot;0 - 0&quot;,
        &quot;characters&quot;: {
          &quot;char1&quot;: &quot;&quot;,
          &quot;char2&quot;: &quot;&quot;
        },
        &quot;notes&quot;: &quot;Filler Character&quot;
      }
    ]
  }
  </code></pre>
  <p>What the program saves:</p>
  <pre><code>{players: [{id: Nebula, setCount: 0 - 0, characters: {char1: ice_climbers, char2: captain_falcon}, notes: }]}
  </code></pre>
  <p>Do I need to manually add the quotes back into the JSON, or is there a different way of saving them?</p>