diff --git a/lib/src/shared/form/bloc/form_bloc.dart b/lib/src/shared/form/bloc/form_bloc.dart index e97a53b2..3d10f478 100644 --- a/lib/src/shared/form/bloc/form_bloc.dart +++ b/lib/src/shared/form/bloc/form_bloc.dart @@ -6,6 +6,7 @@ import 'package:fpdart/fpdart.dart'; part 'form_event.dart'; part 'form_state.dart'; +// FIXME: Utilise TaskEither for async validation class FormBloc extends Bloc { FormBloc({required this.validators, required this.debounce}) : super(const FormState()) { @@ -44,7 +45,7 @@ class FormBloc extends Bloc { ); on((event, emit) { - emit(state.copyWith(shouldDisplayError: event.displayError)); + emit(state.copyWith(shouldDisplayError: event.showError)); }); } diff --git a/lib/src/shared/form/bloc/form_event.dart b/lib/src/shared/form/bloc/form_event.dart index 31edc58f..e686d8b0 100644 --- a/lib/src/shared/form/bloc/form_event.dart +++ b/lib/src/shared/form/bloc/form_event.dart @@ -1,9 +1,13 @@ part of 'form_bloc.dart'; -sealed class FormEvent extends Equatable {} +sealed class FormEvent extends Equatable { + const FormEvent(); +} /// The form wants to validate itself and should show a loading indicator. class FormValidateRequested extends FormEvent { + const FormValidateRequested(); + @override List get props => []; } @@ -13,7 +17,7 @@ class FormValidateRequested extends FormEvent { /// This event is separated from [FormValidateRequested] /// as this event can be debounced. class FormValidateStarted extends FormEvent { - FormValidateStarted({required this.input}); + const FormValidateStarted({required this.input}); final String input; @override @@ -23,9 +27,9 @@ class FormValidateStarted extends FormEvent { /// The form should either enable/disable displaying /// the error message (if there is an error). class FormToggleErrorDisplay extends FormEvent { - FormToggleErrorDisplay({required this.displayError}); - final bool displayError; + const FormToggleErrorDisplay({required this.showError}); + final bool showError; @override - List get props => [displayError]; + List get props => [showError]; } diff --git a/lib/src/shared/form/widgets/form.dart b/lib/src/shared/form/widgets/form.dart index 9877a59b..71ac8e7f 100644 --- a/lib/src/shared/form/widgets/form.dart +++ b/lib/src/shared/form/widgets/form.dart @@ -91,7 +91,9 @@ class FormBase extends StatelessWidget { inputValidators: inputValidators, onChanged: (input) { if (!state.loading) { - context.read().add(FormValidateRequested()); + context + .read() + .add(const FormValidateRequested()); } context .read() @@ -100,7 +102,7 @@ class FormBase extends StatelessWidget { onEditingComplete: () { context .read() - .add(FormToggleErrorDisplay(displayError: true)); + .add(const FormToggleErrorDisplay(showError: true)); if (state.canSubmit) { onSubmit(state.text); } diff --git a/lib/src/voucher_code/bloc/voucher_state.dart b/lib/src/voucher_code/bloc/voucher_state.dart index 126ddf36..f113bab6 100644 --- a/lib/src/voucher_code/bloc/voucher_state.dart +++ b/lib/src/voucher_code/bloc/voucher_state.dart @@ -17,9 +17,8 @@ class VoucherLoading extends VoucherState { // FIXME: Make error states a common class? class VoucherError extends VoucherState { - final String error; - const VoucherError(this.error); + final String error; @override List get props => [error];