mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
notification overhaul
This commit is contained in:
@@ -1,87 +0,0 @@
|
||||
|
||||
|
||||
class Nutrient {
|
||||
final String name;
|
||||
final String unit;
|
||||
final String rdaType;
|
||||
final String? note;
|
||||
final UpperLimit? ul; // nutrient-level UL (optional)
|
||||
final List<LifeStage> lifeStages;
|
||||
|
||||
Nutrient({
|
||||
required this.name,
|
||||
required this.unit,
|
||||
required this.rdaType,
|
||||
this.note,
|
||||
this.ul,
|
||||
required this.lifeStages,
|
||||
});
|
||||
|
||||
factory Nutrient.fromJson(String name, Map<String, dynamic> json) {
|
||||
return Nutrient(
|
||||
name: name,
|
||||
unit: json['unit'],
|
||||
rdaType: json['rda_type'],
|
||||
note: json['note'],
|
||||
ul: (json['ul'] is Map<String, dynamic>) ? UpperLimit.fromJson(json['ul'] as Map<String, dynamic>) : null,
|
||||
lifeStages: (json['life_stages'] as List)
|
||||
.map((stage) => LifeStage.fromJson(stage))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LifeStage {
|
||||
final String ageRange;
|
||||
final String sex;
|
||||
final double value;
|
||||
final double? valueMin;
|
||||
final double? valueMax;
|
||||
final double? ul;
|
||||
final String? description;
|
||||
|
||||
LifeStage({
|
||||
required this.ageRange,
|
||||
required this.sex,
|
||||
required this.value,
|
||||
this.valueMin,
|
||||
this.valueMax,
|
||||
this.ul,
|
||||
this.description,
|
||||
});
|
||||
|
||||
factory LifeStage.fromJson(Map<String, dynamic> json) {
|
||||
return LifeStage(
|
||||
ageRange: json['age_range'],
|
||||
sex: json['sex'],
|
||||
value: (json['value'] as num?)?.toDouble() ?? 0.0,
|
||||
valueMin: json['value_min'] != null ? (json['value_min'] as num).toDouble() : null,
|
||||
valueMax: json['value_max'] != null ? (json['value_max'] as num).toDouble() : null,
|
||||
ul: json['ul'] != null ? (json['ul'] as num).toDouble() : null,
|
||||
description: json['description'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UpperLimit {
|
||||
final double value;
|
||||
final String unit;
|
||||
final String? duration;
|
||||
final String? note;
|
||||
|
||||
const UpperLimit({
|
||||
required this.value,
|
||||
required this.unit,
|
||||
this.duration,
|
||||
this.note,
|
||||
});
|
||||
|
||||
factory UpperLimit.fromJson(Map<String, dynamic> json) {
|
||||
return UpperLimit(
|
||||
value: (json['value'] as num).toDouble(),
|
||||
unit: json['unit'] ?? '',
|
||||
duration: json['duration'],
|
||||
note: json['note'],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user