mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
feat: adds RDA for intake of vitamins and certain elements based on
canada health values
This commit is contained in:
@@ -2,8 +2,8 @@ import 'dart:convert';
|
||||
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import 'ingredient.dart';
|
||||
import '../services/database_sync_service.dart';
|
||||
import 'ingredient.dart';
|
||||
|
||||
class Supplement {
|
||||
final int? id;
|
||||
@@ -69,8 +69,7 @@ class Supplement {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
final map = <String, dynamic>{
|
||||
'name': name,
|
||||
'brand': brand,
|
||||
'ingredients': jsonEncode(ingredients.map((ingredient) => ingredient.toMap()).toList()),
|
||||
@@ -86,6 +85,12 @@ class Supplement {
|
||||
'syncStatus': syncStatus.name,
|
||||
'isDeleted': isDeleted ? 1 : 0,
|
||||
};
|
||||
|
||||
if (id != null) {
|
||||
map['id'] = id;
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
factory Supplement.fromMap(Map<String, dynamic> map) {
|
||||
@@ -133,6 +138,7 @@ class Supplement {
|
||||
|
||||
Supplement copyWith({
|
||||
int? id,
|
||||
bool setNullId = false,
|
||||
String? name,
|
||||
String? brand,
|
||||
List<Ingredient>? ingredients,
|
||||
@@ -144,12 +150,13 @@ class Supplement {
|
||||
DateTime? createdAt,
|
||||
bool? isActive,
|
||||
String? syncId,
|
||||
bool newSyncId = false,
|
||||
DateTime? lastModified,
|
||||
RecordSyncStatus? syncStatus,
|
||||
bool? isDeleted,
|
||||
}) {
|
||||
return Supplement(
|
||||
id: id ?? this.id,
|
||||
id: setNullId ? null : (id ?? this.id),
|
||||
name: name ?? this.name,
|
||||
brand: brand ?? this.brand,
|
||||
ingredients: ingredients ?? this.ingredients,
|
||||
@@ -160,7 +167,7 @@ class Supplement {
|
||||
notes: notes ?? this.notes,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
isActive: isActive ?? this.isActive,
|
||||
syncId: syncId ?? this.syncId,
|
||||
syncId: newSyncId ? null : (syncId ?? this.syncId),
|
||||
lastModified: lastModified ?? this.lastModified,
|
||||
syncStatus: syncStatus ?? this.syncStatus,
|
||||
isDeleted: isDeleted ?? this.isDeleted,
|
||||
|
Reference in New Issue
Block a user