Non-nullable instance field ‘taskTitle’ must be initialized

I'm new to Flutter development and here in my code why i'm getting this error (Non-nullable instance field taskTitle must be initialized), despite of initialising instance field in constructor.

So, I'm assuming that whenever this class instance is created user need to provide both member mendatory, so this error should not occur (although if add late modifier this error disappear).

Please clear my doubts.

class Task {
  String taskTitle;
  bool isDone = false;

  Task(String taskTitle, bool isDone) {
    this.taskTitle = taskTitle;
    this.isDone = isDone;
  }
}


Read more here: https://stackoverflow.com/questions/68404306/non-nullable-instance-field-tasktitle-must-be-initialized

Content Attribution

This content was originally published by Paras at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: