create table

This commit is contained in:
efrilm
2025-10-26 18:47:51 +07:00
parent 634b331716
commit d5ed3f62ff
13 changed files with 949 additions and 228 deletions
@@ -23,19 +23,44 @@ class TableFormBloc extends Bloc<TableFormEvent, TableFormState> {
Emitter<TableFormState> emit,
) {
return event.map(
updated: (e) async {
nameChanged: (e) async {
emit(state.copyWith(name: e.name));
},
capacityChanged: (e) async {
emit(state.copyWith(capacity: int.tryParse(e.capacity) ?? 0));
},
created: (e) async {
Either<TableFailure, Table> failureOrTable;
emit(state.copyWith(isCreating: true, failureOrTable: none()));
final isNameValid = state.name.isNotEmpty;
final isCapacityValid = state.capacity > 0;
if (isNameValid && isCapacityValid) {
failureOrTable = await _repository.createTable(
name: state.name,
capacity: state.capacity,
);
emit(
state.copyWith(
failureOrTable: optionOf(failureOrTable),
isCreating: false,
),
);
}
emit(state.copyWith(failureOrTable: none(), isCreating: false));
},
updated: (e) async {
emit(state.copyWith(isUpdating: true, failureOrTable: none()));
failureOrTable = await _repository.updatePosition(
id: e.id,
position: e.position,
);
await _repository.updatePosition(id: e.id, position: e.position);
emit(
state.copyWith(
failureOrTable: optionOf(failureOrTable),
// failureOrTable: optionOf(failureOrTable),
isUpdating: false,
),
);
@@ -17,40 +17,50 @@ final _privateConstructorUsedError = UnsupportedError(
/// @nodoc
mixin _$TableFormEvent {
String get id => throw _privateConstructorUsedError;
Offset get position => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function(String capacity) capacityChanged,
required TResult Function() created,
required TResult Function(String id, Offset position) updated,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function(String capacity)? capacityChanged,
TResult? Function()? created,
TResult? Function(String id, Offset position)? updated,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function(String capacity)? capacityChanged,
TResult Function()? created,
TResult Function(String id, Offset position)? updated,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_CapacityChanged value) capacityChanged,
required TResult Function(_Created value) created,
required TResult Function(_Updated value) updated,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_CapacityChanged value)? capacityChanged,
TResult? Function(_Created value)? created,
TResult? Function(_Updated value)? updated,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_CapacityChanged value)? capacityChanged,
TResult Function(_Created value)? created,
TResult Function(_Updated value)? updated,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$TableFormEventCopyWith<TableFormEvent> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
@@ -59,8 +69,6 @@ abstract class $TableFormEventCopyWith<$Res> {
TableFormEvent value,
$Res Function(TableFormEvent) then,
) = _$TableFormEventCopyWithImpl<$Res, TableFormEvent>;
@useResult
$Res call({String id, Offset position});
}
/// @nodoc
@@ -73,35 +81,447 @@ class _$TableFormEventCopyWithImpl<$Res, $Val extends TableFormEvent>
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$NameChangedImplCopyWith<$Res> {
factory _$$NameChangedImplCopyWith(
_$NameChangedImpl value,
$Res Function(_$NameChangedImpl) then,
) = __$$NameChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String name});
}
/// @nodoc
class __$$NameChangedImplCopyWithImpl<$Res>
extends _$TableFormEventCopyWithImpl<$Res, _$NameChangedImpl>
implements _$$NameChangedImplCopyWith<$Res> {
__$$NameChangedImplCopyWithImpl(
_$NameChangedImpl _value,
$Res Function(_$NameChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? id = null, Object? position = null}) {
$Res call({Object? name = null}) {
return _then(
_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
position: null == position
? _value.position
: position // ignore: cast_nullable_to_non_nullable
as Offset,
)
as $Val,
_$NameChangedImpl(
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
abstract class _$$UpdatedImplCopyWith<$Res>
implements $TableFormEventCopyWith<$Res> {
class _$NameChangedImpl implements _NameChanged {
const _$NameChangedImpl(this.name);
@override
final String name;
@override
String toString() {
return 'TableFormEvent.nameChanged(name: $name)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$NameChangedImpl &&
(identical(other.name, name) || other.name == name));
}
@override
int get hashCode => Object.hash(runtimeType, name);
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$NameChangedImplCopyWith<_$NameChangedImpl> get copyWith =>
__$$NameChangedImplCopyWithImpl<_$NameChangedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function(String capacity) capacityChanged,
required TResult Function() created,
required TResult Function(String id, Offset position) updated,
}) {
return nameChanged(name);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function(String capacity)? capacityChanged,
TResult? Function()? created,
TResult? Function(String id, Offset position)? updated,
}) {
return nameChanged?.call(name);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function(String capacity)? capacityChanged,
TResult Function()? created,
TResult Function(String id, Offset position)? updated,
required TResult orElse(),
}) {
if (nameChanged != null) {
return nameChanged(name);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_CapacityChanged value) capacityChanged,
required TResult Function(_Created value) created,
required TResult Function(_Updated value) updated,
}) {
return nameChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_CapacityChanged value)? capacityChanged,
TResult? Function(_Created value)? created,
TResult? Function(_Updated value)? updated,
}) {
return nameChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_CapacityChanged value)? capacityChanged,
TResult Function(_Created value)? created,
TResult Function(_Updated value)? updated,
required TResult orElse(),
}) {
if (nameChanged != null) {
return nameChanged(this);
}
return orElse();
}
}
abstract class _NameChanged implements TableFormEvent {
const factory _NameChanged(final String name) = _$NameChangedImpl;
String get name;
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$NameChangedImplCopyWith<_$NameChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$CapacityChangedImplCopyWith<$Res> {
factory _$$CapacityChangedImplCopyWith(
_$CapacityChangedImpl value,
$Res Function(_$CapacityChangedImpl) then,
) = __$$CapacityChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String capacity});
}
/// @nodoc
class __$$CapacityChangedImplCopyWithImpl<$Res>
extends _$TableFormEventCopyWithImpl<$Res, _$CapacityChangedImpl>
implements _$$CapacityChangedImplCopyWith<$Res> {
__$$CapacityChangedImplCopyWithImpl(
_$CapacityChangedImpl _value,
$Res Function(_$CapacityChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? capacity = null}) {
return _then(
_$CapacityChangedImpl(
null == capacity
? _value.capacity
: capacity // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$CapacityChangedImpl implements _CapacityChanged {
const _$CapacityChangedImpl(this.capacity);
@override
final String capacity;
@override
String toString() {
return 'TableFormEvent.capacityChanged(capacity: $capacity)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CapacityChangedImpl &&
(identical(other.capacity, capacity) ||
other.capacity == capacity));
}
@override
int get hashCode => Object.hash(runtimeType, capacity);
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CapacityChangedImplCopyWith<_$CapacityChangedImpl> get copyWith =>
__$$CapacityChangedImplCopyWithImpl<_$CapacityChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function(String capacity) capacityChanged,
required TResult Function() created,
required TResult Function(String id, Offset position) updated,
}) {
return capacityChanged(capacity);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function(String capacity)? capacityChanged,
TResult? Function()? created,
TResult? Function(String id, Offset position)? updated,
}) {
return capacityChanged?.call(capacity);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function(String capacity)? capacityChanged,
TResult Function()? created,
TResult Function(String id, Offset position)? updated,
required TResult orElse(),
}) {
if (capacityChanged != null) {
return capacityChanged(capacity);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_CapacityChanged value) capacityChanged,
required TResult Function(_Created value) created,
required TResult Function(_Updated value) updated,
}) {
return capacityChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_CapacityChanged value)? capacityChanged,
TResult? Function(_Created value)? created,
TResult? Function(_Updated value)? updated,
}) {
return capacityChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_CapacityChanged value)? capacityChanged,
TResult Function(_Created value)? created,
TResult Function(_Updated value)? updated,
required TResult orElse(),
}) {
if (capacityChanged != null) {
return capacityChanged(this);
}
return orElse();
}
}
abstract class _CapacityChanged implements TableFormEvent {
const factory _CapacityChanged(final String capacity) = _$CapacityChangedImpl;
String get capacity;
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CapacityChangedImplCopyWith<_$CapacityChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$CreatedImplCopyWith<$Res> {
factory _$$CreatedImplCopyWith(
_$CreatedImpl value,
$Res Function(_$CreatedImpl) then,
) = __$$CreatedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$CreatedImplCopyWithImpl<$Res>
extends _$TableFormEventCopyWithImpl<$Res, _$CreatedImpl>
implements _$$CreatedImplCopyWith<$Res> {
__$$CreatedImplCopyWithImpl(
_$CreatedImpl _value,
$Res Function(_$CreatedImpl) _then,
) : super(_value, _then);
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$CreatedImpl implements _Created {
const _$CreatedImpl();
@override
String toString() {
return 'TableFormEvent.created()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$CreatedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function(String capacity) capacityChanged,
required TResult Function() created,
required TResult Function(String id, Offset position) updated,
}) {
return created();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function(String capacity)? capacityChanged,
TResult? Function()? created,
TResult? Function(String id, Offset position)? updated,
}) {
return created?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function(String capacity)? capacityChanged,
TResult Function()? created,
TResult Function(String id, Offset position)? updated,
required TResult orElse(),
}) {
if (created != null) {
return created();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_CapacityChanged value) capacityChanged,
required TResult Function(_Created value) created,
required TResult Function(_Updated value) updated,
}) {
return created(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_CapacityChanged value)? capacityChanged,
TResult? Function(_Created value)? created,
TResult? Function(_Updated value)? updated,
}) {
return created?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_CapacityChanged value)? capacityChanged,
TResult Function(_Created value)? created,
TResult Function(_Updated value)? updated,
required TResult orElse(),
}) {
if (created != null) {
return created(this);
}
return orElse();
}
}
abstract class _Created implements TableFormEvent {
const factory _Created() = _$CreatedImpl;
}
/// @nodoc
abstract class _$$UpdatedImplCopyWith<$Res> {
factory _$$UpdatedImplCopyWith(
_$UpdatedImpl value,
$Res Function(_$UpdatedImpl) then,
) = __$$UpdatedImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String id, Offset position});
}
@@ -174,6 +594,9 @@ class _$UpdatedImpl implements _Updated {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function(String capacity) capacityChanged,
required TResult Function() created,
required TResult Function(String id, Offset position) updated,
}) {
return updated(id, position);
@@ -182,6 +605,9 @@ class _$UpdatedImpl implements _Updated {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function(String capacity)? capacityChanged,
TResult? Function()? created,
TResult? Function(String id, Offset position)? updated,
}) {
return updated?.call(id, position);
@@ -190,6 +616,9 @@ class _$UpdatedImpl implements _Updated {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function(String capacity)? capacityChanged,
TResult Function()? created,
TResult Function(String id, Offset position)? updated,
required TResult orElse(),
}) {
@@ -202,6 +631,9 @@ class _$UpdatedImpl implements _Updated {
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_CapacityChanged value) capacityChanged,
required TResult Function(_Created value) created,
required TResult Function(_Updated value) updated,
}) {
return updated(this);
@@ -210,6 +642,9 @@ class _$UpdatedImpl implements _Updated {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_CapacityChanged value)? capacityChanged,
TResult? Function(_Created value)? created,
TResult? Function(_Updated value)? updated,
}) {
return updated?.call(this);
@@ -218,6 +653,9 @@ class _$UpdatedImpl implements _Updated {
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_CapacityChanged value)? capacityChanged,
TResult Function(_Created value)? created,
TResult Function(_Updated value)? updated,
required TResult orElse(),
}) {
@@ -234,14 +672,11 @@ abstract class _Updated implements TableFormEvent {
required final Offset position,
}) = _$UpdatedImpl;
@override
String get id;
@override
Offset get position;
/// Create a copy of TableFormEvent
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UpdatedImplCopyWith<_$UpdatedImpl> get copyWith =>
throw _privateConstructorUsedError;
@@ -249,9 +684,12 @@ abstract class _Updated implements TableFormEvent {
/// @nodoc
mixin _$TableFormState {
String get name => throw _privateConstructorUsedError;
int get capacity => throw _privateConstructorUsedError;
Option<Either<TableFailure, Table>> get failureOrTable =>
throw _privateConstructorUsedError;
bool get isUpdating => throw _privateConstructorUsedError;
bool get isCreating => throw _privateConstructorUsedError;
/// Create a copy of TableFormState
/// with the given fields replaced by the non-null parameter values.
@@ -268,8 +706,11 @@ abstract class $TableFormStateCopyWith<$Res> {
) = _$TableFormStateCopyWithImpl<$Res, TableFormState>;
@useResult
$Res call({
String name,
int capacity,
Option<Either<TableFailure, Table>> failureOrTable,
bool isUpdating,
bool isCreating,
});
}
@@ -287,9 +728,23 @@ class _$TableFormStateCopyWithImpl<$Res, $Val extends TableFormState>
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? failureOrTable = null, Object? isUpdating = null}) {
$Res call({
Object? name = null,
Object? capacity = null,
Object? failureOrTable = null,
Object? isUpdating = null,
Object? isCreating = null,
}) {
return _then(
_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
capacity: null == capacity
? _value.capacity
: capacity // ignore: cast_nullable_to_non_nullable
as int,
failureOrTable: null == failureOrTable
? _value.failureOrTable
: failureOrTable // ignore: cast_nullable_to_non_nullable
@@ -298,6 +753,10 @@ class _$TableFormStateCopyWithImpl<$Res, $Val extends TableFormState>
? _value.isUpdating
: isUpdating // ignore: cast_nullable_to_non_nullable
as bool,
isCreating: null == isCreating
? _value.isCreating
: isCreating // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
@@ -314,8 +773,11 @@ abstract class _$$TableFormStateImplCopyWith<$Res>
@override
@useResult
$Res call({
String name,
int capacity,
Option<Either<TableFailure, Table>> failureOrTable,
bool isUpdating,
bool isCreating,
});
}
@@ -332,9 +794,23 @@ class __$$TableFormStateImplCopyWithImpl<$Res>
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? failureOrTable = null, Object? isUpdating = null}) {
$Res call({
Object? name = null,
Object? capacity = null,
Object? failureOrTable = null,
Object? isUpdating = null,
Object? isCreating = null,
}) {
return _then(
_$TableFormStateImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
capacity: null == capacity
? _value.capacity
: capacity // ignore: cast_nullable_to_non_nullable
as int,
failureOrTable: null == failureOrTable
? _value.failureOrTable
: failureOrTable // ignore: cast_nullable_to_non_nullable
@@ -343,6 +819,10 @@ class __$$TableFormStateImplCopyWithImpl<$Res>
? _value.isUpdating
: isUpdating // ignore: cast_nullable_to_non_nullable
as bool,
isCreating: null == isCreating
? _value.isCreating
: isCreating // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
@@ -351,17 +831,30 @@ class __$$TableFormStateImplCopyWithImpl<$Res>
/// @nodoc
class _$TableFormStateImpl implements _TableFormState {
_$TableFormStateImpl({required this.failureOrTable, this.isUpdating = false});
_$TableFormStateImpl({
required this.name,
required this.capacity,
required this.failureOrTable,
this.isUpdating = false,
this.isCreating = false,
});
@override
final String name;
@override
final int capacity;
@override
final Option<Either<TableFailure, Table>> failureOrTable;
@override
@JsonKey()
final bool isUpdating;
@override
@JsonKey()
final bool isCreating;
@override
String toString() {
return 'TableFormState(failureOrTable: $failureOrTable, isUpdating: $isUpdating)';
return 'TableFormState(name: $name, capacity: $capacity, failureOrTable: $failureOrTable, isUpdating: $isUpdating, isCreating: $isCreating)';
}
@override
@@ -369,14 +862,26 @@ class _$TableFormStateImpl implements _TableFormState {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$TableFormStateImpl &&
(identical(other.name, name) || other.name == name) &&
(identical(other.capacity, capacity) ||
other.capacity == capacity) &&
(identical(other.failureOrTable, failureOrTable) ||
other.failureOrTable == failureOrTable) &&
(identical(other.isUpdating, isUpdating) ||
other.isUpdating == isUpdating));
other.isUpdating == isUpdating) &&
(identical(other.isCreating, isCreating) ||
other.isCreating == isCreating));
}
@override
int get hashCode => Object.hash(runtimeType, failureOrTable, isUpdating);
int get hashCode => Object.hash(
runtimeType,
name,
capacity,
failureOrTable,
isUpdating,
isCreating,
);
/// Create a copy of TableFormState
/// with the given fields replaced by the non-null parameter values.
@@ -392,14 +897,23 @@ class _$TableFormStateImpl implements _TableFormState {
abstract class _TableFormState implements TableFormState {
factory _TableFormState({
required final String name,
required final int capacity,
required final Option<Either<TableFailure, Table>> failureOrTable,
final bool isUpdating,
final bool isCreating,
}) = _$TableFormStateImpl;
@override
String get name;
@override
int get capacity;
@override
Option<Either<TableFailure, Table>> get failureOrTable;
@override
bool get isUpdating;
@override
bool get isCreating;
/// Create a copy of TableFormState
/// with the given fields replaced by the non-null parameter values.
@@ -2,6 +2,10 @@ part of 'table_form_bloc.dart';
@freezed
class TableFormEvent with _$TableFormEvent {
const factory TableFormEvent.nameChanged(String name) = _NameChanged;
const factory TableFormEvent.capacityChanged(String capacity) =
_CapacityChanged;
const factory TableFormEvent.created() = _Created;
const factory TableFormEvent.updated({
required String id,
required Offset position,
@@ -3,9 +3,13 @@ part of 'table_form_bloc.dart';
@freezed
class TableFormState with _$TableFormState {
factory TableFormState({
required String name,
required int capacity,
required Option<Either<TableFailure, Table>> failureOrTable,
@Default(false) bool isUpdating,
@Default(false) bool isCreating,
}) = _TableFormState;
factory TableFormState.initial() => TableFormState(failureOrTable: none());
factory TableFormState.initial() =>
TableFormState(failureOrTable: none(), name: '', capacity: 0);
}