fix!(form): fix states with required form
This commit is contained in:
parent
f031b3cbf5
commit
ae3711a136
@ -16,24 +16,21 @@
|
|||||||
|
|
||||||
part of 'form_data_cubit.dart';
|
part of 'form_data_cubit.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
|
||||||
abstract class FormDataState extends Equatable {
|
abstract class FormDataState extends Equatable {
|
||||||
/// Global status of a form.
|
/// Global status of a form.
|
||||||
final FormStatus status;
|
final FormStatus status;
|
||||||
|
|
||||||
/// FormData with all inputs, and associated metadata.
|
/// FormData with all inputs, and associated metadata.
|
||||||
late WyattForm form;
|
final WyattForm form;
|
||||||
|
|
||||||
/// Optional error message.
|
/// Optional error message.
|
||||||
final String? errorMessage;
|
final String? errorMessage;
|
||||||
|
|
||||||
FormDataState({
|
const FormDataState({
|
||||||
WyattForm? form,
|
required this.form,
|
||||||
this.status = FormStatus.pure,
|
this.status = FormStatus.pure,
|
||||||
this.errorMessage,
|
this.errorMessage,
|
||||||
}) {
|
});
|
||||||
this.form = form ?? WyattFormImpl(const [], name: '');
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [status, form, errorMessage];
|
List<Object?> get props => [status, form, errorMessage];
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
part of 'form_data_cubit_impl.dart';
|
part of 'form_data_cubit_impl.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
|
||||||
class FormDataStateImpl extends FormDataState {
|
class FormDataStateImpl extends FormDataState {
|
||||||
FormDataStateImpl({
|
const FormDataStateImpl({
|
||||||
required super.form,
|
required super.form,
|
||||||
super.status = FormStatus.pure,
|
super.status = FormStatus.pure,
|
||||||
super.errorMessage,
|
super.errorMessage,
|
||||||
@ -39,6 +38,6 @@ class FormDataStateImpl extends FormDataState {
|
|||||||
List<Object?> get props => [status, form, errorMessage];
|
List<Object?> get props => [status, form, errorMessage];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() =>
|
String toString() => 'FormDataSate(status: ${status.name} '
|
||||||
'FormDataSate(status: ${status.name} ${(errorMessage != null) ? " [$errorMessage]" : ""}, $form';
|
'${(errorMessage != null) ? " [$errorMessage]" : ""}, $form)';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user