title: auto converting json to object in dart flutter
body: <p>I search google and stackoverflow but did not find some auto converting lib like in C#</p>
  <p>I need something in dart-flutter alternative to this code in C#</p>
  <pre><code>    string jsonTokenData = &quot;{my token json data}&quot;;
      TokenModel getTokenModel = Newtonsoft.Json.JsonConvert.DeserializeObject&lt;GetTokenModel&gt;(jsonTokenData);
  </code></pre>
  <blockquote>
  <p>Update</p>
  </blockquote>
  <ul>
  <li>I read the Documentation and I know how to map models with json</li>
  <li>this question to who know how Newtonsoft lib work on C#</li>
  <li>if you do not know Newtonsoft: the Idea is to convert json data to a model automatically without writing map for each model. Also I know there is a tool to create that map with json for each model automatically but still make code ridiculous.</li>
  </ul>
  <blockquote>
  <p>Update2: as I get a suggestion from community for a similar question that not answer my question. so this is a another explanation:</p>
  </blockquote>
  <p>I have a lot of models these models are updated by time as clients requested or adding new features to some models.
  so when an update happen I just need to add the extra properties that has been added to these models, I do not need to warry every time about mapping, spell mistaken or using some tools again to regenerate these codes.</p>
  <p>so I'm asking for a function that take two parameters</p>
  <ul>
  <li>first one is the type of the model</li>
  <li>second one the json string that hold the data</li>
  </ul>
  <p><strong>[then in return is an object instance of the passed type]</strong></p>
  <p>for simple example if I have this class:</p>
  <pre><code>class Car {
      String name;
      String type;
  }
  </code></pre>
  <p>Then I could keep it clean this way without getting it dart with other methods:</p>
  <pre><code>Car({
          this.name,
          this.type,
      });
  
      factory Car.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Car(
          name: json[&quot;name&quot;],
          type: json[&quot;type&quot;],
      );
  
      Map&lt;String, dynamic&gt; toJson() =&gt; {
          &quot;name&quot;: name,
          &quot;type&quot;: type,
      };
  </code></pre>
  <p>by the way lib in C# is also take care about arrays, lists and nested classes</p>
  <p>I hope this time it explained well</p>