feat: add alot

This commit is contained in:
2026-10-08 04:12:36 +02:00
parent ccf5165417
commit fc607cb7bd
99 changed files with 4981 additions and 3655 deletions
+21 -13
View File
@@ -1,12 +1,14 @@
import 'dart:io';
import 'dart:async';
import 'dart:io';
import 'package:drift/drift.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:drift/drift.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:uuid/uuid.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:uuid/uuid.dart';
import '../database/app_database.dart';
@@ -52,7 +54,9 @@ class DefaultProductSeeder {
imagePath = await _copyBundledImage(name, imagesDir);
}
await database.into(database.products).insert(
await database
.into(database.products)
.insert(
ProductsCompanion.insert(
id: uuid.v4(),
name: name,
@@ -67,7 +71,7 @@ class DefaultProductSeeder {
});
} catch (e, stack) {
debugPrint('DefaultProductSeeder: seedIfEmpty error: $e');
Sentry.captureException(e, stackTrace: stack);
unawaited(Sentry.captureException(e, stackTrace: stack));
}
}
@@ -95,7 +99,10 @@ class DefaultProductSeeder {
}
}
Future<String?> _copyBundledImage(String productName, Directory imagesDir) async {
Future<String?> _copyBundledImage(
String productName,
Directory imagesDir,
) async {
final slug = _toSlug(productName);
for (final ext in ['png', 'jpg', 'webp']) {
@@ -107,10 +114,9 @@ class DefaultProductSeeder {
final destPath = path.join(imagesDir.path, fileName);
final destFile = File(destPath);
await destFile.writeAsBytes(bytes.buffer.asUint8List(
bytes.offsetInBytes,
bytes.lengthInBytes,
));
await destFile.writeAsBytes(
bytes.buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes),
);
return destPath;
} catch (_) {
@@ -118,8 +124,10 @@ class DefaultProductSeeder {
}
}
debugPrint('DefaultProductSeeder: no bundled image found for "$productName" '
'(looked for assets/products/$slug.{png,jpg,webp})');
debugPrint(
'DefaultProductSeeder: no bundled image found for "$productName" '
'(looked for assets/products/$slug.{png,jpg,webp})',
);
return null;
}