【发布时间】:2021-01-20 19:13:57
【问题描述】:
大家好,我正在关注关于 DDD 的 reso coder 系列,我在第八部分遇到错误,这是我的代码:
return BlocConsumer<SignInFormBloc, SignInFormState>(
builder: (context, state) {},
listener: (context, state) {});
这是错误:
The following NoSuchMethodError was thrown building BlocConsumer<SignInFormBloc, SignInFormState>:
The getter 'state' was called on null.
Receiver: null
Tried calling: state
这是 sign_in_form_state 代码:
part of 'sign_in_form_bloc.dart';
@freezed
abstract class SignInFormState with _$SignInFormState {
const factory SignInFormState({
@required EmailAddress emailAddress,
@required Password password,
@required bool showErrorMessages,
@required bool isSubmitting,
@required Option<Either<AuthFailure, Unit>> authFailureOrSuccessOption,
}) = _SignInFormState;
factory SignInFormState.initial() => SignInFormState(
emailAddress: EmailAddress(' '),
password: Password(' '),
showErrorMessages: false,
isSubmitting: false,
authFailureOrSuccessOption: none(),
);
}
提前致谢。
【问题讨论】:
-
贴出相关代码,你在哪里使用state?
标签: flutter domain-driven-design bloc