'How can I solved this error in flutter class code

I write this class

class Profile {
  String email;
  String password;

  Profile({this.email, this.password});
}

But it said that

"The parameter 'email' can't have a value of 'null' because of its type, but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.dartmissing_default_value_for_parameter"


Solution 1:[1]

You have to make them accept a null value.

class Profile {
  String? email;
  String? password;

  Profile({this.email, this.password});
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 erik7854