void emailChanged(String value) {
final email = Email.dirty(value);
emit(state.copyWith(
email: email,
status: Formz.validate([email, state.password]),
));
}
这是我的简单功能。状态给出错误我不知道为什么。所有软件包都已安装(flutter_bloc)。为什么它给出一个错误?
Undefined name 'state'.
Try correcting the name to one that is defined, or defining the name
我的状态:
part of 'login_cubit.dart';
class LoginState extends Equatable {
const LoginState({
this.email = const Email.pure(),
this.password = const Password.pure(),
this.username = const Username.pure(),
this.status = FormzStatus.pure,
this.exceptionError = "",
});
final Email email;
final Username username;
final Password password;
final FormzStatus status;
final String exceptionError;
@override
List<Object> get props =>
[email, username, password, status, exceptionError];
LoginState copyWith({
Email? email,
Username? username,
Password? password,
FormzStatus? status,
String? exceptionError,
}) {
return LoginState(
email: email ?? this.email,
username: username ?? this.username,
password: password ?? this.password,
status: status ?? this.status,
exceptionError: exceptionError ?? this.exceptionError,
);
}
}
昨天没报错,是不是包坏了?