DietaryGuard/lib/models/alert_configuration.dart

51 lines
1.1 KiB
Dart
Raw Permalink Normal View History

2024-08-15 14:50:00 +00:00
import 'package:dietary_guard/models/food_data.dart';
2024-08-15 03:53:01 +00:00
class AlertConfiguration {
2024-08-15 14:50:00 +00:00
String name;
2024-08-15 03:53:01 +00:00
int nutrientId;
double maxValue;
double minValue;
AlertConfiguration({
2024-08-15 14:50:00 +00:00
required this.name,
2024-08-15 03:53:01 +00:00
required this.nutrientId,
required this.maxValue,
required this.minValue,
});
Map<String, dynamic> toJson() => {
2024-08-15 14:50:00 +00:00
'name': name,
2024-08-15 03:53:01 +00:00
'nutrient_id': nutrientId,
'min_value': minValue,
'max_value': maxValue,
};
factory AlertConfiguration.fromJson(Map<String, dynamic> json) =>
AlertConfiguration(
2024-08-15 14:50:00 +00:00
name: json['name'],
2024-08-15 03:53:01 +00:00
nutrientId: json['nutrient_id'],
minValue: json['min_value'],
maxValue: json['max_value'],
);
}
2024-08-15 07:57:58 +00:00
class AlertDetectResult {
AlertConfiguration config;
2024-08-15 14:50:00 +00:00
FoodNutrient? nutrient;
2024-08-15 07:57:58 +00:00
String name;
String? unitName;
double? difference;
bool isOutOfRange;
bool isUndetected;
AlertDetectResult({
required this.config,
2024-08-15 14:50:00 +00:00
required this.nutrient,
2024-08-15 07:57:58 +00:00
required this.name,
required this.unitName,
required this.difference,
required this.isOutOfRange,
required this.isUndetected,
});
}