printer receipt

This commit is contained in:
efrilm
2025-11-04 22:13:15 +07:00
parent a87b62ca9f
commit 1b24bae23a
32 changed files with 4177 additions and 75 deletions
@@ -0,0 +1,38 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../../domain/printer/printer.dart';
part 'bluetooth_connect_event.dart';
part 'bluetooth_connect_state.dart';
part 'bluetooth_connect_bloc.freezed.dart';
@injectable
class BluetoothConnectBloc
extends Bloc<BluetoothConnectEvent, BluetoothConnectState> {
final IPrinterRepository _printerRepository;
BluetoothConnectBloc(this._printerRepository)
: super(BluetoothConnectState.initial()) {
on<BluetoothConnectEvent>(_onBluetoothConnectEvent);
}
Future<void> _onBluetoothConnectEvent(
BluetoothConnectEvent event,
Emitter<BluetoothConnectState> emit,
) {
return event.map(
connect: (e) async {
emit(state.copyWith(isConnecting: true, failureOrSuccee: none()));
final result = await _printerRepository.connectBluetooth(e.macAddress);
result.fold(
(failure) => emit(state.copyWith(isConnecting: false)),
(success) => emit(state.copyWith(isConnecting: false)),
);
},
);
}
}
@@ -0,0 +1,404 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'bluetooth_connect_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$BluetoothConnectEvent {
String get macAddress => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String macAddress) connect,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String macAddress)? connect,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String macAddress)? connect,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Connect value) connect,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Connect value)? connect,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Connect value)? connect,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
/// Create a copy of BluetoothConnectEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$BluetoothConnectEventCopyWith<BluetoothConnectEvent> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $BluetoothConnectEventCopyWith<$Res> {
factory $BluetoothConnectEventCopyWith(
BluetoothConnectEvent value,
$Res Function(BluetoothConnectEvent) then,
) = _$BluetoothConnectEventCopyWithImpl<$Res, BluetoothConnectEvent>;
@useResult
$Res call({String macAddress});
}
/// @nodoc
class _$BluetoothConnectEventCopyWithImpl<
$Res,
$Val extends BluetoothConnectEvent
>
implements $BluetoothConnectEventCopyWith<$Res> {
_$BluetoothConnectEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of BluetoothConnectEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? macAddress = null}) {
return _then(
_value.copyWith(
macAddress: null == macAddress
? _value.macAddress
: macAddress // ignore: cast_nullable_to_non_nullable
as String,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$ConnectImplCopyWith<$Res>
implements $BluetoothConnectEventCopyWith<$Res> {
factory _$$ConnectImplCopyWith(
_$ConnectImpl value,
$Res Function(_$ConnectImpl) then,
) = __$$ConnectImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String macAddress});
}
/// @nodoc
class __$$ConnectImplCopyWithImpl<$Res>
extends _$BluetoothConnectEventCopyWithImpl<$Res, _$ConnectImpl>
implements _$$ConnectImplCopyWith<$Res> {
__$$ConnectImplCopyWithImpl(
_$ConnectImpl _value,
$Res Function(_$ConnectImpl) _then,
) : super(_value, _then);
/// Create a copy of BluetoothConnectEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? macAddress = null}) {
return _then(
_$ConnectImpl(
null == macAddress
? _value.macAddress
: macAddress // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$ConnectImpl implements _Connect {
const _$ConnectImpl(this.macAddress);
@override
final String macAddress;
@override
String toString() {
return 'BluetoothConnectEvent.connect(macAddress: $macAddress)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ConnectImpl &&
(identical(other.macAddress, macAddress) ||
other.macAddress == macAddress));
}
@override
int get hashCode => Object.hash(runtimeType, macAddress);
/// Create a copy of BluetoothConnectEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ConnectImplCopyWith<_$ConnectImpl> get copyWith =>
__$$ConnectImplCopyWithImpl<_$ConnectImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String macAddress) connect,
}) {
return connect(macAddress);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String macAddress)? connect,
}) {
return connect?.call(macAddress);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String macAddress)? connect,
required TResult orElse(),
}) {
if (connect != null) {
return connect(macAddress);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Connect value) connect,
}) {
return connect(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Connect value)? connect,
}) {
return connect?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Connect value)? connect,
required TResult orElse(),
}) {
if (connect != null) {
return connect(this);
}
return orElse();
}
}
abstract class _Connect implements BluetoothConnectEvent {
const factory _Connect(final String macAddress) = _$ConnectImpl;
@override
String get macAddress;
/// Create a copy of BluetoothConnectEvent
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ConnectImplCopyWith<_$ConnectImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$BluetoothConnectState {
Option<Either<PrinterFailure, bool>> get failureOrSuccee =>
throw _privateConstructorUsedError;
bool get isConnecting => throw _privateConstructorUsedError;
/// Create a copy of BluetoothConnectState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$BluetoothConnectStateCopyWith<BluetoothConnectState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $BluetoothConnectStateCopyWith<$Res> {
factory $BluetoothConnectStateCopyWith(
BluetoothConnectState value,
$Res Function(BluetoothConnectState) then,
) = _$BluetoothConnectStateCopyWithImpl<$Res, BluetoothConnectState>;
@useResult
$Res call({
Option<Either<PrinterFailure, bool>> failureOrSuccee,
bool isConnecting,
});
}
/// @nodoc
class _$BluetoothConnectStateCopyWithImpl<
$Res,
$Val extends BluetoothConnectState
>
implements $BluetoothConnectStateCopyWith<$Res> {
_$BluetoothConnectStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of BluetoothConnectState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? failureOrSuccee = null, Object? isConnecting = null}) {
return _then(
_value.copyWith(
failureOrSuccee: null == failureOrSuccee
? _value.failureOrSuccee
: failureOrSuccee // ignore: cast_nullable_to_non_nullable
as Option<Either<PrinterFailure, bool>>,
isConnecting: null == isConnecting
? _value.isConnecting
: isConnecting // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$BluetoothConnectStateImplCopyWith<$Res>
implements $BluetoothConnectStateCopyWith<$Res> {
factory _$$BluetoothConnectStateImplCopyWith(
_$BluetoothConnectStateImpl value,
$Res Function(_$BluetoothConnectStateImpl) then,
) = __$$BluetoothConnectStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
Option<Either<PrinterFailure, bool>> failureOrSuccee,
bool isConnecting,
});
}
/// @nodoc
class __$$BluetoothConnectStateImplCopyWithImpl<$Res>
extends
_$BluetoothConnectStateCopyWithImpl<$Res, _$BluetoothConnectStateImpl>
implements _$$BluetoothConnectStateImplCopyWith<$Res> {
__$$BluetoothConnectStateImplCopyWithImpl(
_$BluetoothConnectStateImpl _value,
$Res Function(_$BluetoothConnectStateImpl) _then,
) : super(_value, _then);
/// Create a copy of BluetoothConnectState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? failureOrSuccee = null, Object? isConnecting = null}) {
return _then(
_$BluetoothConnectStateImpl(
failureOrSuccee: null == failureOrSuccee
? _value.failureOrSuccee
: failureOrSuccee // ignore: cast_nullable_to_non_nullable
as Option<Either<PrinterFailure, bool>>,
isConnecting: null == isConnecting
? _value.isConnecting
: isConnecting // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$BluetoothConnectStateImpl implements _BluetoothConnectState {
_$BluetoothConnectStateImpl({
required this.failureOrSuccee,
this.isConnecting = false,
});
@override
final Option<Either<PrinterFailure, bool>> failureOrSuccee;
@override
@JsonKey()
final bool isConnecting;
@override
String toString() {
return 'BluetoothConnectState(failureOrSuccee: $failureOrSuccee, isConnecting: $isConnecting)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$BluetoothConnectStateImpl &&
(identical(other.failureOrSuccee, failureOrSuccee) ||
other.failureOrSuccee == failureOrSuccee) &&
(identical(other.isConnecting, isConnecting) ||
other.isConnecting == isConnecting));
}
@override
int get hashCode => Object.hash(runtimeType, failureOrSuccee, isConnecting);
/// Create a copy of BluetoothConnectState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$BluetoothConnectStateImplCopyWith<_$BluetoothConnectStateImpl>
get copyWith =>
__$$BluetoothConnectStateImplCopyWithImpl<_$BluetoothConnectStateImpl>(
this,
_$identity,
);
}
abstract class _BluetoothConnectState implements BluetoothConnectState {
factory _BluetoothConnectState({
required final Option<Either<PrinterFailure, bool>> failureOrSuccee,
final bool isConnecting,
}) = _$BluetoothConnectStateImpl;
@override
Option<Either<PrinterFailure, bool>> get failureOrSuccee;
@override
bool get isConnecting;
/// Create a copy of BluetoothConnectState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$BluetoothConnectStateImplCopyWith<_$BluetoothConnectStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,6 @@
part of 'bluetooth_connect_bloc.dart';
@freezed
class BluetoothConnectEvent with _$BluetoothConnectEvent {
const factory BluetoothConnectEvent.connect(String macAddress) = _Connect;
}
@@ -0,0 +1,12 @@
part of 'bluetooth_connect_bloc.dart';
@freezed
class BluetoothConnectState with _$BluetoothConnectState {
factory BluetoothConnectState({
required Option<Either<PrinterFailure, bool>> failureOrSuccee,
@Default(false) bool isConnecting,
}) = _BluetoothConnectState;
factory BluetoothConnectState.initial() =>
BluetoothConnectState(failureOrSuccee: none());
}
@@ -0,0 +1,95 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../common/function/app_function.dart';
import '../../../domain/printer/printer.dart';
part 'printer_form_event.dart';
part 'printer_form_state.dart';
part 'printer_form_bloc.freezed.dart';
@injectable
class PrinterFormBloc extends Bloc<PrinterFormEvent, PrinterFormState> {
final IPrinterRepository _printerRepository;
PrinterFormBloc(this._printerRepository) : super(PrinterFormState.initial()) {
on<PrinterFormEvent>(_onPrinterFormEvent);
}
Future<void> _onPrinterFormEvent(
PrinterFormEvent event,
Emitter<PrinterFormState> emit,
) {
return event.map(
codeChanged: (e) async {
emit(state.copyWith(code: e.code));
},
nameChanged: (e) async {
emit(state.copyWith(name: e.name));
},
addressChanged: (e) async {
emit(state.copyWith(address: e.address));
},
typeChanged: (e) async {
emit(state.copyWith(type: e.type));
},
paperChanged: (e) async {
emit(state.copyWith(paper: e.paper));
},
created: (e) async {
Either<PrinterFailure, Unit> failureOrPrinter;
emit(state.copyWith(isCreating: true, failureOrCreateSuccess: none()));
final request = Printer(
id: generateRandomNumber(),
code: state.code,
name: state.name,
address: state.address,
paper: state.paper,
type: state.type,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
failureOrPrinter = await _printerRepository.createPrinter(request);
emit(
state.copyWith(
isCreating: false,
failureOrCreateSuccess: optionOf(failureOrPrinter),
),
);
},
updated: (e) async {
Either<PrinterFailure, Unit> failureOrPrinter;
emit(state.copyWith(isUpdate: true, failureOrUpdateSuccess: none()));
final request = Printer(
id: generateRandomNumber(),
code: state.code,
name: state.name,
address: state.address,
paper: state.paper,
type: state.type,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
failureOrPrinter = await _printerRepository.updatePrinter(
request,
e.id,
);
emit(
state.copyWith(
isUpdate: false,
failureOrUpdateSuccess: optionOf(failureOrPrinter),
),
);
},
);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,13 @@
part of 'printer_form_bloc.dart';
@freezed
class PrinterFormEvent with _$PrinterFormEvent {
const factory PrinterFormEvent.codeChanged(String code) = _CodeChanged;
const factory PrinterFormEvent.nameChanged(String name) = _NameChanged;
const factory PrinterFormEvent.addressChanged(String address) =
_AddressChanged;
const factory PrinterFormEvent.typeChanged(String type) = _TypeChanged;
const factory PrinterFormEvent.paperChanged(String paper) = _PaperChanged;
const factory PrinterFormEvent.created() = _Created;
const factory PrinterFormEvent.updated(int id) = _Updated;
}
@@ -0,0 +1,26 @@
part of 'printer_form_bloc.dart';
@freezed
class PrinterFormState with _$PrinterFormState {
factory PrinterFormState({
required String code,
required String name,
required String address,
required String paper,
required String type,
required Option<Either<PrinterFailure, Unit>> failureOrCreateSuccess,
required Option<Either<PrinterFailure, Unit>> failureOrUpdateSuccess,
@Default(false) isCreating,
@Default(false) isUpdate,
}) = _PrinterFormState;
factory PrinterFormState.initial() => PrinterFormState(
code: '',
name: '',
address: '',
paper: '58',
type: 'Bluetooth',
failureOrCreateSuccess: none(),
failureOrUpdateSuccess: none(),
);
}
@@ -0,0 +1,46 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/printer/printer.dart';
part 'printer_loader_event.dart';
part 'printer_loader_state.dart';
part 'printer_loader_bloc.freezed.dart';
@injectable
class PrinterLoaderBloc extends Bloc<PrinterLoaderEvent, PrinterLoaderState> {
final IPrinterRepository _printerRepository;
PrinterLoaderBloc(this._printerRepository)
: super(PrinterLoaderState.initial()) {
on<PrinterLoaderEvent>(_onPrinterLoaderEvent);
}
Future<void> _onPrinterLoaderEvent(
PrinterLoaderEvent event,
Emitter<PrinterLoaderState> emit,
) {
return event.map(
getByCode: (e) async {
emit(state.copyWith(isFetching: true, failureOption: none()));
final result = await _printerRepository.getPrinterByCode(e.code);
await result.fold(
(failure) async {
emit(
state.copyWith(
isFetching: false,
failureOption: optionOf(failure),
),
);
},
(printer) async {
emit(state.copyWith(isFetching: false, printer: printer));
},
);
},
);
}
}
@@ -0,0 +1,437 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'printer_loader_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$PrinterLoaderEvent {
String get code => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String code) getByCode,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String code)? getByCode,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String code)? getByCode,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_GetByCode value) getByCode,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_GetByCode value)? getByCode,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_GetByCode value)? getByCode,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
/// Create a copy of PrinterLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$PrinterLoaderEventCopyWith<PrinterLoaderEvent> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $PrinterLoaderEventCopyWith<$Res> {
factory $PrinterLoaderEventCopyWith(
PrinterLoaderEvent value,
$Res Function(PrinterLoaderEvent) then,
) = _$PrinterLoaderEventCopyWithImpl<$Res, PrinterLoaderEvent>;
@useResult
$Res call({String code});
}
/// @nodoc
class _$PrinterLoaderEventCopyWithImpl<$Res, $Val extends PrinterLoaderEvent>
implements $PrinterLoaderEventCopyWith<$Res> {
_$PrinterLoaderEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of PrinterLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? code = null}) {
return _then(
_value.copyWith(
code: null == code
? _value.code
: code // ignore: cast_nullable_to_non_nullable
as String,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$GetByCodeImplCopyWith<$Res>
implements $PrinterLoaderEventCopyWith<$Res> {
factory _$$GetByCodeImplCopyWith(
_$GetByCodeImpl value,
$Res Function(_$GetByCodeImpl) then,
) = __$$GetByCodeImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String code});
}
/// @nodoc
class __$$GetByCodeImplCopyWithImpl<$Res>
extends _$PrinterLoaderEventCopyWithImpl<$Res, _$GetByCodeImpl>
implements _$$GetByCodeImplCopyWith<$Res> {
__$$GetByCodeImplCopyWithImpl(
_$GetByCodeImpl _value,
$Res Function(_$GetByCodeImpl) _then,
) : super(_value, _then);
/// Create a copy of PrinterLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? code = null}) {
return _then(
_$GetByCodeImpl(
null == code
? _value.code
: code // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$GetByCodeImpl implements _GetByCode {
const _$GetByCodeImpl(this.code);
@override
final String code;
@override
String toString() {
return 'PrinterLoaderEvent.getByCode(code: $code)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$GetByCodeImpl &&
(identical(other.code, code) || other.code == code));
}
@override
int get hashCode => Object.hash(runtimeType, code);
/// Create a copy of PrinterLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GetByCodeImplCopyWith<_$GetByCodeImpl> get copyWith =>
__$$GetByCodeImplCopyWithImpl<_$GetByCodeImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String code) getByCode,
}) {
return getByCode(code);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String code)? getByCode,
}) {
return getByCode?.call(code);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String code)? getByCode,
required TResult orElse(),
}) {
if (getByCode != null) {
return getByCode(code);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_GetByCode value) getByCode,
}) {
return getByCode(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_GetByCode value)? getByCode,
}) {
return getByCode?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_GetByCode value)? getByCode,
required TResult orElse(),
}) {
if (getByCode != null) {
return getByCode(this);
}
return orElse();
}
}
abstract class _GetByCode implements PrinterLoaderEvent {
const factory _GetByCode(final String code) = _$GetByCodeImpl;
@override
String get code;
/// Create a copy of PrinterLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GetByCodeImplCopyWith<_$GetByCodeImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$PrinterLoaderState {
Printer get printer => throw _privateConstructorUsedError;
Option<PrinterFailure> get failureOption =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
/// Create a copy of PrinterLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$PrinterLoaderStateCopyWith<PrinterLoaderState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $PrinterLoaderStateCopyWith<$Res> {
factory $PrinterLoaderStateCopyWith(
PrinterLoaderState value,
$Res Function(PrinterLoaderState) then,
) = _$PrinterLoaderStateCopyWithImpl<$Res, PrinterLoaderState>;
@useResult
$Res call({
Printer printer,
Option<PrinterFailure> failureOption,
bool isFetching,
});
$PrinterCopyWith<$Res> get printer;
}
/// @nodoc
class _$PrinterLoaderStateCopyWithImpl<$Res, $Val extends PrinterLoaderState>
implements $PrinterLoaderStateCopyWith<$Res> {
_$PrinterLoaderStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of PrinterLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? printer = null,
Object? failureOption = null,
Object? isFetching = null,
}) {
return _then(
_value.copyWith(
printer: null == printer
? _value.printer
: printer // ignore: cast_nullable_to_non_nullable
as Printer,
failureOption: null == failureOption
? _value.failureOption
: failureOption // ignore: cast_nullable_to_non_nullable
as Option<PrinterFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of PrinterLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$PrinterCopyWith<$Res> get printer {
return $PrinterCopyWith<$Res>(_value.printer, (value) {
return _then(_value.copyWith(printer: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$PrinterLoaderStateImplCopyWith<$Res>
implements $PrinterLoaderStateCopyWith<$Res> {
factory _$$PrinterLoaderStateImplCopyWith(
_$PrinterLoaderStateImpl value,
$Res Function(_$PrinterLoaderStateImpl) then,
) = __$$PrinterLoaderStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
Printer printer,
Option<PrinterFailure> failureOption,
bool isFetching,
});
@override
$PrinterCopyWith<$Res> get printer;
}
/// @nodoc
class __$$PrinterLoaderStateImplCopyWithImpl<$Res>
extends _$PrinterLoaderStateCopyWithImpl<$Res, _$PrinterLoaderStateImpl>
implements _$$PrinterLoaderStateImplCopyWith<$Res> {
__$$PrinterLoaderStateImplCopyWithImpl(
_$PrinterLoaderStateImpl _value,
$Res Function(_$PrinterLoaderStateImpl) _then,
) : super(_value, _then);
/// Create a copy of PrinterLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? printer = null,
Object? failureOption = null,
Object? isFetching = null,
}) {
return _then(
_$PrinterLoaderStateImpl(
printer: null == printer
? _value.printer
: printer // ignore: cast_nullable_to_non_nullable
as Printer,
failureOption: null == failureOption
? _value.failureOption
: failureOption // ignore: cast_nullable_to_non_nullable
as Option<PrinterFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$PrinterLoaderStateImpl implements _PrinterLoaderState {
_$PrinterLoaderStateImpl({
required this.printer,
required this.failureOption,
this.isFetching = false,
});
@override
final Printer printer;
@override
final Option<PrinterFailure> failureOption;
@override
@JsonKey()
final bool isFetching;
@override
String toString() {
return 'PrinterLoaderState(printer: $printer, failureOption: $failureOption, isFetching: $isFetching)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PrinterLoaderStateImpl &&
(identical(other.printer, printer) || other.printer == printer) &&
(identical(other.failureOption, failureOption) ||
other.failureOption == failureOption) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching));
}
@override
int get hashCode =>
Object.hash(runtimeType, printer, failureOption, isFetching);
/// Create a copy of PrinterLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PrinterLoaderStateImplCopyWith<_$PrinterLoaderStateImpl> get copyWith =>
__$$PrinterLoaderStateImplCopyWithImpl<_$PrinterLoaderStateImpl>(
this,
_$identity,
);
}
abstract class _PrinterLoaderState implements PrinterLoaderState {
factory _PrinterLoaderState({
required final Printer printer,
required final Option<PrinterFailure> failureOption,
final bool isFetching,
}) = _$PrinterLoaderStateImpl;
@override
Printer get printer;
@override
Option<PrinterFailure> get failureOption;
@override
bool get isFetching;
/// Create a copy of PrinterLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PrinterLoaderStateImplCopyWith<_$PrinterLoaderStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -0,0 +1,6 @@
part of 'printer_loader_bloc.dart';
@freezed
class PrinterLoaderEvent with _$PrinterLoaderEvent {
const factory PrinterLoaderEvent.getByCode(String code) = _GetByCode;
}
@@ -0,0 +1,13 @@
part of 'printer_loader_bloc.dart';
@freezed
class PrinterLoaderState with _$PrinterLoaderState {
factory PrinterLoaderState({
required Printer printer,
required Option<PrinterFailure> failureOption,
@Default(false) bool isFetching,
}) = _PrinterLoaderState;
factory PrinterLoaderState.initial() =>
PrinterLoaderState(printer: Printer.empty(), failureOption: none());
}