add some new features

This commit is contained in:
2026-10-29 15:03:48 +01:00
parent c876405a8f
commit 20012db615
39 changed files with 2908 additions and 97 deletions
+8 -1
View File
@@ -6,7 +6,9 @@ class KaufFilamentModel {
final String material;
final double preis;
final String farbe;
// Original net material weight, without the spool.
final String gewicht;
final double? bruttoGewichtGramm;
const KaufFilamentModel({
required this.filamentId,
@@ -17,9 +19,10 @@ class KaufFilamentModel {
required this.preis,
required this.farbe,
required this.gewicht,
this.bruttoGewichtGramm,
});
/// Supports old purchases saved as "1kg" as well as gram values.
/// Original net material weight. Supports legacy "1kg" and gram values.
double? get gewichtGramm {
final match = RegExp(
r'^\s*(\d+(?:[.,]\d+)?)\s*(kg|g)?\s*$',
@@ -41,6 +44,7 @@ class KaufFilamentModel {
'preis': preis,
'farbe': farbe,
'gewicht': gewicht,
'bruttoGewichtGramm': bruttoGewichtGramm,
};
factory KaufFilamentModel.fromJson(Map<String, dynamic> json) {
@@ -53,6 +57,7 @@ class KaufFilamentModel {
preis: (json['preis'] as num).toDouble(),
farbe: json['farbe'] as String,
gewicht: json['gewicht'] ?? '1000',
bruttoGewichtGramm: (json['bruttoGewichtGramm'] as num?)?.toDouble(),
);
}
@@ -65,6 +70,7 @@ class KaufFilamentModel {
double? preis,
String? farbe,
String? gewicht,
double? bruttoGewichtGramm,
}) {
return KaufFilamentModel(
filamentId: filamentId ?? this.filamentId,
@@ -75,6 +81,7 @@ class KaufFilamentModel {
preis: preis ?? this.preis,
farbe: farbe ?? this.farbe,
gewicht: gewicht ?? this.gewicht,
bruttoGewichtGramm: bruttoGewichtGramm ?? this.bruttoGewichtGramm,
);
}
}