feat: add equality operators, make history screen paginated, random performance updates

This commit is contained in:
2026-07-29 18:10:46 +02:00
parent da5588cd1c
commit 031a618220
22 changed files with 702 additions and 79 deletions
+31
View File
@@ -30,4 +30,35 @@ class BarTab {
}
bool get isOpen => status == 'open';
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BarTab &&
id == other.id &&
customerName == other.customerName &&
status == other.status &&
openedAt == other.openedAt &&
closedAt == other.closedAt &&
_listEquals(items, other.items);
@override
int get hashCode => Object.hash(
id,
customerName,
status,
openedAt,
closedAt,
Object.hashAll(items),
);
}
bool _listEquals<T>(List<T>? a, List<T>? b) {
if (identical(a, b)) return true;
if (a == null || b == null) return a == b;
if (a.length != b.length) return false;
for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) return false;
}
return true;
}
+29
View File
@@ -24,4 +24,33 @@ class ClosedTab {
String get formattedTotal =>
NumberFormat.simpleCurrency().format(totalInCents / 100);
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ClosedTab &&
id == other.id &&
originalTabId == other.originalTabId &&
customerName == other.customerName &&
closedAt == other.closedAt &&
_listEquals(items, other.items);
@override
int get hashCode => Object.hash(
id,
originalTabId,
customerName,
closedAt,
Object.hashAll(items),
);
}
bool _listEquals<T>(List<T>? a, List<T>? b) {
if (identical(a, b)) return true;
if (a == null || b == null) return a == b;
if (a.length != b.length) return false;
for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) return false;
}
return true;
}
+21
View File
@@ -16,4 +16,25 @@ class ClosedTabItem {
});
int get lineTotalInCents => quantity * unitPriceInCents;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ClosedTabItem &&
id == other.id &&
closedTabId == other.closedTabId &&
productId == other.productId &&
productName == other.productName &&
quantity == other.quantity &&
unitPriceInCents == other.unitPriceInCents;
@override
int get hashCode => Object.hash(
id,
closedTabId,
productId,
productName,
quantity,
unitPriceInCents,
);
}
+25
View File
@@ -48,4 +48,29 @@ class Product {
active: active ?? this.active,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Product &&
id == other.id &&
name == other.name &&
category == other.category &&
stockQuantity == other.stockQuantity &&
lowStockThreshold == other.lowStockThreshold &&
priceInCents == other.priceInCents &&
imagePath == other.imagePath &&
active == other.active;
@override
int get hashCode => Object.hash(
id,
name,
category,
stockQuantity,
lowStockThreshold,
priceInCents,
imagePath,
active,
);
}
+10
View File
@@ -17,4 +17,14 @@ class AppSettings {
pinRequired: false,
themeMode: AppThemeMode.system,
);
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is AppSettings &&
pinRequired == other.pinRequired &&
themeMode == other.themeMode;
@override
int get hashCode => Object.hash(pinRequired, themeMode);
}
+21
View File
@@ -24,4 +24,25 @@ class TabItem {
String get formattedUnitPrice {
return '${(unitPriceInCents / 100).toStringAsFixed(2)}';
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TabItem &&
id == other.id &&
tabId == other.tabId &&
productId == other.productId &&
productName == other.productName &&
quantity == other.quantity &&
unitPriceInCents == other.unitPriceInCents;
@override
int get hashCode => Object.hash(
id,
tabId,
productId,
productName,
quantity,
unitPriceInCents,
);
}