title: Flutter class error , Try adding an initializer expression, or add a field initializer in this constructor, or mark it
body: <p>Hi I'm trying to create generic API response class in flutter application and I'm getting this error</p>
  <pre><code>class ApiResponse&lt;T&gt; {
    Status status;
    T data;
    String message;
  
    ApiResponse.loading(this.message) : status = Status.LOADING;
    ApiResponse.completed(this.data) : status = Status.COMPLETED;
    ApiResponse.error(this.message) : status = Status.ERROR;
  
    @override
    String toString() {
      return &quot;Status : $status \n Message : $message \n Data : $data&quot;;
    }
  }
  
  enum Status { LOADING, COMPLETED, ERROR }
  </code></pre>
  <p>IDE complains about below error</p>
  <p><strong>Non-nullable instance field 'data' must be initialized.
  Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'</strong></p>
  <p>Could anyone tell me what is wrong wiht my code?</p>