runable
This commit is contained in:
71
lib/features/scanner/domain/entities/scan_entity.dart
Normal file
71
lib/features/scanner/domain/entities/scan_entity.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Domain entity representing a scan item
|
||||
/// This is the business logic representation without any external dependencies
|
||||
class ScanEntity extends Equatable {
|
||||
final String barcode;
|
||||
final DateTime timestamp;
|
||||
final String field1;
|
||||
final String field2;
|
||||
final String field3;
|
||||
final String field4;
|
||||
|
||||
const ScanEntity({
|
||||
required this.barcode,
|
||||
required this.timestamp,
|
||||
this.field1 = '',
|
||||
this.field2 = '',
|
||||
this.field3 = '',
|
||||
this.field4 = '',
|
||||
});
|
||||
|
||||
/// Create a copy with updated fields
|
||||
ScanEntity copyWith({
|
||||
String? barcode,
|
||||
DateTime? timestamp,
|
||||
String? field1,
|
||||
String? field2,
|
||||
String? field3,
|
||||
String? field4,
|
||||
}) {
|
||||
return ScanEntity(
|
||||
barcode: barcode ?? this.barcode,
|
||||
timestamp: timestamp ?? this.timestamp,
|
||||
field1: field1 ?? this.field1,
|
||||
field2: field2 ?? this.field2,
|
||||
field3: field3 ?? this.field3,
|
||||
field4: field4 ?? this.field4,
|
||||
);
|
||||
}
|
||||
|
||||
/// Check if the entity has any form data
|
||||
bool get hasFormData {
|
||||
return field1.isNotEmpty ||
|
||||
field2.isNotEmpty ||
|
||||
field3.isNotEmpty ||
|
||||
field4.isNotEmpty;
|
||||
}
|
||||
|
||||
/// Check if all form fields are filled
|
||||
bool get isFormComplete {
|
||||
return field1.isNotEmpty &&
|
||||
field2.isNotEmpty &&
|
||||
field3.isNotEmpty &&
|
||||
field4.isNotEmpty;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object> get props => [
|
||||
barcode,
|
||||
timestamp,
|
||||
field1,
|
||||
field2,
|
||||
field3,
|
||||
field4,
|
||||
];
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ScanEntity{barcode: $barcode, timestamp: $timestamp, field1: $field1, field2: $field2, field3: $field3, field4: $field4}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user