Flutter - How to parsed nested json to a class with generics? : <p>I'm wondering how can I parse a nested json to a class with generic types. My intention is to wrap responses from the backend (like loginRespose that contains a token) with a code and a message</p>

<p>I have </p>

<pre><code>class BaseResponse&lt;T&gt;{
  int code;
  String message;
  T responseObject;

  BaseResponse.fromJson(Map&lt;String, dynamic&gt; parsedJson)
    : code = parsedJson['Code'],
      message = parsedJson['Message'],
      responseObject = T.fromJson(parsedJson['ResponseObject']); //This is what I'd like to do
}
</code></pre>

<p>Obviously the last line throws an error because T doesn't has a named constructor "fromJson".
I tried adding some restrictions to the Type but I didn't find any solutions. Do you have any idea on how to pull this off?</p>
