fix!(form): fix states with required form

This commit is contained in:
Hugo Pointcheval 2022-11-10 13:24:00 -05:00
parent f031b3cbf5
commit ae3711a136
Signed by: hugo
GPG Key ID: A9E8E9615379254F
2 changed files with 7 additions and 11 deletions

View File

@ -16,24 +16,21 @@
part of 'form_data_cubit.dart';
// ignore: must_be_immutable
abstract class FormDataState extends Equatable {
/// Global status of a form.
final FormStatus status;
/// FormData with all inputs, and associated metadata.
late WyattForm form;
final WyattForm form;
/// Optional error message.
final String? errorMessage;
FormDataState({
WyattForm? form,
const FormDataState({
required this.form,
this.status = FormStatus.pure,
this.errorMessage,
}) {
this.form = form ?? WyattFormImpl(const [], name: '');
}
});
@override
List<Object?> get props => [status, form, errorMessage];

View File

@ -16,9 +16,8 @@
part of 'form_data_cubit_impl.dart';
// ignore: must_be_immutable
class FormDataStateImpl extends FormDataState {
FormDataStateImpl({
const FormDataStateImpl({
required super.form,
super.status = FormStatus.pure,
super.errorMessage,
@ -39,6 +38,6 @@ class FormDataStateImpl extends FormDataState {
List<Object?> get props => [status, form, errorMessage];
@override
String toString() =>
'FormDataSate(status: ${status.name} ${(errorMessage != null) ? " [$errorMessage]" : ""}, $form';
String toString() => 'FormDataSate(status: ${status.name} '
'${(errorMessage != null) ? " [$errorMessage]" : ""}, $form)';
}