Flutter-Ernaehrungsapp/lib/helper/setup_todaybox.dart

22 lines
515 B
Dart
Raw Permalink Normal View History

2023-05-29 12:08:46 +02:00
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:hive/hive.dart';
import '../models/food.dart';
final List<Food> emptyList = [];
void setupTodayBox() async{
2023-06-25 14:43:07 +02:00
final todayBox = Hive.box(dotenv.env['TODAY_BOX']!);
putIfKeyNotExists(todayBox, 'FRÜHSTÜCK', []);
putIfKeyNotExists(todayBox, 'MITTAGESSEN', []);
putIfKeyNotExists(todayBox, 'ABENDESSEN', []);
2023-05-29 12:08:46 +02:00
}
void putIfKeyNotExists(Box box, String key, List<Food> value) {
if (!box.containsKey(key)) {
box.put(key, value);
2023-05-29 12:08:46 +02:00
}
}