From 7f49500db85741b763121d1785548034dfd3ca0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Gonz=C3=A1lez?= Date: Mon, 13 Apr 2026 12:17:47 +0200 Subject: [PATCH] allow duplicates in database, and start of web server --- Makefile | 7 +++++++ lib/corpus.dart | 7 ------- lib/main.dart | 4 +++- pubspec.lock | 16 ++++++++++++++++ pubspec.yaml | 2 ++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index add553f..4f8fdf9 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,13 @@ build-linux-debug-container: build-web-debug-container: $(FLUTTERW) build web --debug +# Zip web build for embedding as asset +assets/generated/webapp.zip: build/web + mkdir -p assets/generated + cd build/web && zip -r ../../assets/generated/webapp.zip . + +build-webapp-zip: assets/generated/webapp.zip + run-linux-debug-container: $(FLUTTERW) run -d linux diff --git a/lib/corpus.dart b/lib/corpus.dart index 28c7cd1..aecd35b 100644 --- a/lib/corpus.dart +++ b/lib/corpus.dart @@ -245,13 +245,6 @@ class Corpus{ loadFormulas(formulas, replaceOnDuplicates: replaceOnDuplicates, checkUnits: true); } - /// Loads corpus from database elements - static Future fromDatabaseElements(List elements) async { - final corpus = Corpus(); - corpus.loadFormulaElements(elements); - return corpus; - } - /// Returns the formula, the units of the formula, and all the units from the corpus with the same base unit. List withDependencies(Formula formula) { final result = {}; diff --git a/lib/main.dart b/lib/main.dart index 963180c..d2cdd97 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -142,7 +142,9 @@ Future loadCorpusFromDatabaseOrAssets() async { return defaultCorpus; } else { // Load corpus from database elements - return await Corpus.fromDatabaseElements(dbElements); + final corpus = Corpus(); + corpus.loadFormulaElements(dbElements, true); + return corpus; } } catch (e, st) { // If there's an error loading from database, fall back to default corpus diff --git a/pubspec.lock b/pubspec.lock index cfbcee2..1c604da 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -17,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "8.4.1" + archive: + dependency: "direct main" + description: + name: archive + sha256: a96e8b390886ee8abb49b7bd3ac8df6f451c621619f52a26e815fdcf568959ff + url: "https://pub.dev" + source: hosted + version: "4.0.9" args: dependency: transitive description: @@ -688,6 +696,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.2" + posix: + dependency: transitive + description: + name: posix + sha256: "185ef7606574f789b40f289c233efa52e96dead518aed988e040a10737febb07" + url: "https://pub.dev" + source: hosted + version: "6.5.0" provider: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index edeadaa..ec95943 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,6 +53,7 @@ dependencies: collection: share_plus: receive_sharing_intent: + archive: ^4.0.9 dev_dependencies: flutter_test: @@ -88,6 +89,7 @@ flutter: assets: - assets/units/ - assets/formulas/ + - assets/generated/webapp.zip # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/to/resolution-aware-images