我正在尝试使用Freezed对接口进行编程。我希望能够在我的应用程序中指定类型IUserRegistrationEntity
;
我的界面:
abstract class IUserRegistrationEntity {
String nickName;
String email;
String confirmEmail;
String password;
String confirmPassword;
}
我的冻结班:
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:vepo/domain/user_registration/i_user_registration_entity.dart';
part 'user_registration_entity.freezed.dart';
@freezed
abstract class UserRegistrationEntity with _$UserRegistrationEntity {
@Implements(IUserRegistrationEntity)
factory UserRegistrationEntity(
{String nickName,
String email,
String confirmEmail,
String password,
String confirmPassword}) = _UserRegistrationEntity;
}
运行应用程序时出现错误:
lib/domain/user_registration/user_registration_entity.freezed.dart:165:7: Error: The non-abstract class '_$_UserRegistrationEntity' is missing implementations for these members:
- IUserRegistrationEntity.confirmEmail
- IUserRegistrationEntity.confirmPassword
- IUserRegistrationEntity.email
- IUserRegistrationEntity.nickName
- IUserRegistrationEntity.password
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class _$_UserRegistrationEntity implements _UserRegistrationEntity {
^^^^^^^^^^^^^^^^^^^^^^^^^
lib/domain/user_registration/i_user_registration_entity.dart:4:10: Context: 'IUserRegistrationEntity.confirmEmail' is defined here.
String confirmEmail;
^^^^^^^^^^^^
lib/domain/user_registration/i_user_registration_entity.dart:6:10: Context: 'IUserRegistrationEntity.confirmPassword' is defined here.
String confirmPassword;
^^^^^^^^^^^^^^^
lib/domain/user_registration/i_user_registration_entity.dart:3:10: Context: 'IUserRegistrationEntity.email' is defined here.
String email;
^^^^^
lib/domain/user_registration/i_user_registration_entity.dart:2:10: Context: 'IUserRegistrationEntity.nickName' is defined here.
String nickName;
^^^^^^^^
lib/domain/user_registration/i_user_registration_entity.dart:5:10: Context: 'IUserRegistrationEntity.password' is defined here.
String password;
^^^^^^^^
我究竟做错了什么?
编辑:包文档中的这句话是否意味着不可能?
注意 2:您不能将 @With/@Implements 与冻结的类一起使用。冻结的类既不能扩展也不能实现。
很想知道人们是否认为这是一个缺点。