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
+21 -7
View File
@@ -36,6 +36,7 @@ class _ProductFormViewState extends State<ProductFormView> {
Product? _existingProduct;
String? _imagePath;
bool _hasImage = false;
bool _isLoading = true;
bool _isSaving = false;
@@ -72,6 +73,7 @@ class _ProductFormViewState extends State<ProductFormView> {
_stockController.text = product.stockQuantity.toString();
_lowStockController.text = product.lowStockThreshold.toString();
_imagePath = product.imagePath;
_hasImage = product.imagePath != null && product.imagePath!.isNotEmpty;
setState(() => _isLoading = false);
}
@@ -108,10 +110,11 @@ class _ProductFormViewState extends State<ProductFormView> {
Future<void> _pickImage() async {
final pickedFile = await _imagePicker.pickImage(
source: ImageSource.gallery,
imageQuality: 85,
maxWidth: 1000,
);
source: ImageSource.gallery,
imageQuality: 80,
maxWidth: 1000,
maxHeight: 1000,
);
if (pickedFile == null) return;
@@ -121,6 +124,7 @@ class _ProductFormViewState extends State<ProductFormView> {
setState(() {
_imagePath = copiedImagePath;
_hasImage = true;
});
}
@@ -222,7 +226,6 @@ class _ProductFormViewState extends State<ProductFormView> {
}
Widget _buildImagePicker(BuildContext context) {
final hasImage = _imagePath != null && File(_imagePath!).existsSync();
return InkWell(
onTap: _pickImage,
@@ -234,11 +237,22 @@ class _ProductFormViewState extends State<ProductFormView> {
border: Border.all(color: Theme.of(context).colorScheme.outline),
),
clipBehavior: Clip.antiAlias,
child: hasImage
child: _hasImage
? Stack(
fit: StackFit.expand,
children: [
Image.file(File(_imagePath!), fit: BoxFit.fitHeight),
Image.file(
File(_imagePath!),
fit: BoxFit.fitHeight,
cacheWidth: 1000,
errorBuilder: (context, error, stackTrace) => Center(
child: Icon(
Icons.broken_image_outlined,
size: 48,
color: Theme.of(context).colorScheme.outline,
),
),
),
Positioned(
right: 12,
bottom: 12,