【发布时间】:2019-09-14 14:59:40
【问题描述】:
如何将字段设为私有并在课堂上使用@required 对其进行注释?
例如,这段代码给了我错误:
class AuthenticationService {
final Api _api;
AuthenticationService({@required this._api}); // error in this line
}
【问题讨论】:
如何将字段设为私有并在课堂上使用@required 对其进行注释?
例如,这段代码给了我错误:
class AuthenticationService {
final Api _api;
AuthenticationService({@required this._api}); // error in this line
}
【问题讨论】:
class AuthenticationService {
final Api _api;
AuthenticationService({@required Api api}) : _api = api;
}
【讨论】: