Data models¶
The app uses several Dart data classes to represent objects from Part-DB and the local configuration.
Part¶
The main class representing an electronic component.
class Part {
final int id;
final String name;
final String partNumber; // IPN (7-digit identifier)
final String unit; // unit of measure (e.g. "pcs", "m")
final double minAmount; // minimum required stock
final String description;
final String comment;
String category; // category name (filled in separately)
String manufacturer; // manufacturer name (filled in separately)
final String tags;
List<PartLot> partLots; // storage locations
List<PartParameter> parameters;
// Computed fields
double get totalStock; // sum of amount across lots with a known amount
bool get hasUnknownStock; // any lot has instock_unknown
bool get isLowStock; // minAmount > 0 && !hasUnknownStock && totalStock < minAmount
}
| Field | Type | Description |
|---|---|---|
id |
int |
Identifier in Part-DB |
name |
String |
Full part name |
partNumber |
String |
IPN (may be empty) |
unit |
String |
Unit of measure |
minAmount |
double |
Minimum required stock |
description |
String |
Text description |
comment |
String |
Internal comment |
category |
String |
Category name (mutable, filled in after fetching) |
manufacturer |
String |
Manufacturer name (mutable) |
tags |
String |
Comma-separated tags |
partLots |
List<PartLot> |
Locations with quantities |
parameters |
List<PartParameter> |
Technical parameters |
totalStock |
double |
Computed: sum of quantities across partLots (lots with instock_unknown excluded) |
hasUnknownStock |
bool |
Computed: at least one lot has an unknown amount |
isLowStock |
bool |
Computed: minAmount > 0 && !hasUnknownStock && totalStock < minAmount |
Note
minAmount is read from the API field minamount. Amounts are floats and are never rounded; the UI formats them with formatAmount() (12, 2.5).
PartLot¶
Represents a storage lot – a quantity at a specific location.
class PartLot {
final int id;
final String locationName;
final String locationIri;
final String description;
String comment;
final bool instockUnknown;
double amount;
}
| Field | Type | Description |
|---|---|---|
id |
int |
Lot identifier in Part-DB |
locationName |
String |
Location name (drawer, shelf…) |
amount |
double |
Quantity at this location |
description |
String |
Lot description (never modified by the app) |
comment |
String |
Lot comment; stock notes are prepended here as dated lines |
instockUnknown |
bool |
The amount at this location is unknown |
PartParameter¶
A single technical parameter of a part.
class PartParameter {
final int id;
final String name;
String value; // display value
final String unit;
final String? editableField; // 'value_text', 'value_typical' or null (range)
final String editableValue; // raw value of editableField
}
| Field | Type | Description |
|---|---|---|
id |
int |
Parameter identifier in Part-DB |
name |
String |
Parameter name (e.g. "Value", "Package") |
value |
String |
Text value (parsed from several possible API fields) |
unit |
String |
Unit (e.g. "Ω", "F", "V") |
editableField |
String? |
API field the app writes back to; null for min/max ranges (read-only) |
Value parsing
The display value comes from formatted, then value_text, then value_typical, then value_min … value_max. The collection endpoint returns parameter names only; values come from GET /api/parts/{id}.
ApiException¶
The exception thrown by ApiService on an HTTP or parsing error.
Used to show detailed error messages in the UI (SnackBar).
LabelConfig¶
Configuration of the Niimbot label parameters, persisted through SharedPreferences.
class LabelConfig {
List<LabelParamEntry> entries;
// Serialization to/from JSON
// Storage: SharedPreferences key 'niimbot_label_params'
}
class LabelParamEntry {
final String name; // parameter name
bool enabled; // whether to print this parameter
bool bold; // whether it is bold
}
| Field | Type | Description |
|---|---|---|
name |
String |
Parameter name (must match PartParameter.name) |
enabled |
bool |
Whether the parameter is enabled on the label |
bold |
bool |
Whether the parameter is printed in bold |
LabelConfig implements merge logic: every time the print screen is opened, the current list of part parameters is merged with the saved configuration. New parameters are appended at the end as enabled and non-bold; removed parameters are skipped.
HistoryEntry¶
An entry in the history of recently viewed parts. Stored as JSON in SharedPreferences.
The history is limited to the 20 most recent entries. Duplicates (the same id) are removed when a new entry is added.