我寫這門課
class Profile {
String email;
String password;
Profile({this.email, this.password});
}
但它說
"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"
uj5u.com熱心網友回復:
通過添加必需的:
class Profile {
String email;
String password;
Profile({
required this.email,
required this.password,
});
}
通過添加可選:
class Profile {
String? email;
String? password;
Profile({
this.email,
this.password,
});
}
通過添加默認值:
class Profile {
String email;
String password;
Profile({
this.email = "[email protected]",
this.password = "123",
});
}
uj5u.com熱心網友回復:
你必須讓他們接受一個null價值。
class Profile {
String? email;
String? password;
Profile({this.email, this.password});
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/440089.html
下一篇:如何執行一個類(python)
