The name '_SignInFormState' isn't a type and can't be used in a redirected constructor. Try redirecting to a different constructor. flutter

Viewed 326

I am new to bloc. My error is "The name '_SignInFormState' isn't a type and can't be used in a redirected constructor. Try redirecting to a different constructor. flutter."I generated freezer files. The issue still persists.

part of 'sign_in_form_bloc.dart';

@freezed
abstract class SignInFormState with _$SignInFormState {
  const factory SignInFormState({
    @required String emailAddress,
    @required String password,
    @required bool showErrorMessages,
    @required bool isSubmitting,
    // @required AuthFailureOrSuccess authFailureOrSuccess,
  }) = _SignInFormState;
  factory SignInFormState.initial() => SignInFormState(
        emailAddress: '',
        password: '',
        showErrorMessages: false,
        isSubmitting: false,
        // authFailureOrSuccess: AuthFailureOrSuccess.none(),
      );
}

I generated freezer files. The issue still persists. these is the code from sign_in_form_bloc.dart

@injectable
class SignInFormBloc extends Bloc<SignInFormEvent, SignInFormState> {
  final IAuthFacade _authFacade;

  SignInFormBloc(this._authFacade) : super(SignInFormState.inital());

  @override
  Stream<SignInFormState> mapEventToState(SignInFormEvent event) async* {
    yield* event.map(
      emailChange: (event) async* {
        yield state.copyWith(
          emailAddress: event.email,
          authFailureOrSuccess: AuthFailureOrSuccess.none(),
        );
      },
      passwordChange: (event) async* {
        yield state.copyWith(
          password: event.password,
          authFailureOrSuccess: AuthFailureOrSuccess.none(),
        );
      },
      signInWithEmailAndPassword: (event) async* {
        final String? email = state.emailAddress;
        final String? password = state.password;

        if (validateEmailAddress(email!) && validatePassword(password!)) {
          yield state.copyWith(
            showErrorMessages: false,
            isSubmitting: true,
            authFailureOrSuccess: AuthFailureOrSuccess.none(),
          );

          var result = await _authFacade.signInWithEmailAndPassword(
            emailAddress: email,
            password: password,
          );

          yield state.copyWith(
            isSubmitting: false,
            authFailureOrSuccess: result!.authFailureOrSuccess,
          );
        } else {
          yield state.copyWith(
              showErrorMessages: true,
              authFailureOrSuccess: AuthFailureOrSuccess.none());
        }
      },
    );
  }
}
0 Answers
Related