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
@@ -1 +0,0 @@
part of '../printer.dart';
@@ -0,0 +1,26 @@
part of '../printer.dart';
@freezed
class Printer with _$Printer {
const factory Printer({
required int id,
required String code,
required String name,
required String address,
required String paper,
required String type,
required DateTime createdAt,
required DateTime updatedAt,
}) = _Printer;
factory Printer.empty() => Printer(
id: 0,
code: '',
name: '',
address: '',
paper: '',
type: '',
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
}
+1 -1
View File
@@ -6,6 +6,6 @@ import '../../common/api/api_failure.dart';
part 'printer.freezed.dart';
part 'entities/print_entity.dart';
part 'entities/printer_entity.dart';
part 'failures/printer_failure.dart';
part 'repositories/i_printer_repository.dart';
+292
View File
@@ -15,6 +15,298 @@ 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 _$Printer {
int get id => throw _privateConstructorUsedError;
String get code => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String get address => throw _privateConstructorUsedError;
String get paper => throw _privateConstructorUsedError;
String get type => throw _privateConstructorUsedError;
DateTime get createdAt => throw _privateConstructorUsedError;
DateTime get updatedAt => throw _privateConstructorUsedError;
/// Create a copy of Printer
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$PrinterCopyWith<Printer> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $PrinterCopyWith<$Res> {
factory $PrinterCopyWith(Printer value, $Res Function(Printer) then) =
_$PrinterCopyWithImpl<$Res, Printer>;
@useResult
$Res call({
int id,
String code,
String name,
String address,
String paper,
String type,
DateTime createdAt,
DateTime updatedAt,
});
}
/// @nodoc
class _$PrinterCopyWithImpl<$Res, $Val extends Printer>
implements $PrinterCopyWith<$Res> {
_$PrinterCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Printer
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? code = null,
Object? name = null,
Object? address = null,
Object? paper = null,
Object? type = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(
_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
code: null == code
? _value.code
: code // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
address: null == address
? _value.address
: address // ignore: cast_nullable_to_non_nullable
as String,
paper: null == paper
? _value.paper
: paper // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$PrinterImplCopyWith<$Res> implements $PrinterCopyWith<$Res> {
factory _$$PrinterImplCopyWith(
_$PrinterImpl value,
$Res Function(_$PrinterImpl) then,
) = __$$PrinterImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
int id,
String code,
String name,
String address,
String paper,
String type,
DateTime createdAt,
DateTime updatedAt,
});
}
/// @nodoc
class __$$PrinterImplCopyWithImpl<$Res>
extends _$PrinterCopyWithImpl<$Res, _$PrinterImpl>
implements _$$PrinterImplCopyWith<$Res> {
__$$PrinterImplCopyWithImpl(
_$PrinterImpl _value,
$Res Function(_$PrinterImpl) _then,
) : super(_value, _then);
/// Create a copy of Printer
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? code = null,
Object? name = null,
Object? address = null,
Object? paper = null,
Object? type = null,
Object? createdAt = null,
Object? updatedAt = null,
}) {
return _then(
_$PrinterImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
code: null == code
? _value.code
: code // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
address: null == address
? _value.address
: address // ignore: cast_nullable_to_non_nullable
as String,
paper: null == paper
? _value.paper
: paper // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
class _$PrinterImpl implements _Printer {
const _$PrinterImpl({
required this.id,
required this.code,
required this.name,
required this.address,
required this.paper,
required this.type,
required this.createdAt,
required this.updatedAt,
});
@override
final int id;
@override
final String code;
@override
final String name;
@override
final String address;
@override
final String paper;
@override
final String type;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
@override
String toString() {
return 'Printer(id: $id, code: $code, name: $name, address: $address, paper: $paper, type: $type, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PrinterImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.code, code) || other.code == code) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.address, address) || other.address == address) &&
(identical(other.paper, paper) || other.paper == paper) &&
(identical(other.type, type) || other.type == type) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@override
int get hashCode => Object.hash(
runtimeType,
id,
code,
name,
address,
paper,
type,
createdAt,
updatedAt,
);
/// Create a copy of Printer
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PrinterImplCopyWith<_$PrinterImpl> get copyWith =>
__$$PrinterImplCopyWithImpl<_$PrinterImpl>(this, _$identity);
}
abstract class _Printer implements Printer {
const factory _Printer({
required final int id,
required final String code,
required final String name,
required final String address,
required final String paper,
required final String type,
required final DateTime createdAt,
required final DateTime updatedAt,
}) = _$PrinterImpl;
@override
int get id;
@override
String get code;
@override
String get name;
@override
String get address;
@override
String get paper;
@override
String get type;
@override
DateTime get createdAt;
@override
DateTime get updatedAt;
/// Create a copy of Printer
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PrinterImplCopyWith<_$PrinterImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$PrinterFailure {
@optionalTypeArgs
@@ -6,4 +6,8 @@ abstract class IPrinterRepository {
Future<Either<PrinterFailure, bool>> isBluetoothEnabled();
Future<Either<PrinterFailure, List<BluetoothInfo>>>
getPairedBluetoothDevices();
Future<Either<PrinterFailure, Unit>> createPrinter(Printer printer);
Future<Either<PrinterFailure, Unit>> updatePrinter(Printer printer, int id);
Future<Either<PrinterFailure, Unit>> deletePrinter(int id);
Future<Either<PrinterFailure, Printer>> getPrinterByCode(String code);
}