Flutter-Ernaehrungsapp/lib/android/config/setup_todaybox_config.dart

25 lines
603 B
Dart

import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:hive/hive.dart';
import '../models/food.dart';
final List<Food> emptyList = [];
void setupTodayBox() async{
final todayBox = Hive.box(dotenv.env['MEALPLAN_BOX']!);
putIfKeyNotExists(todayBox, 'FRÜHSTÜCK', []);
putIfKeyNotExists(todayBox, 'MITTAGESSEN', []);
putIfKeyNotExists(todayBox, 'ABENDESSEN', []);
}
void putIfKeyNotExists(Box box, String key, List<Food> value) {
if (!box.containsKey(key)) {
box.put(key, value);
}
}
String getFormatedTodayDate(){
return DateTime.now().toString().substring(0,10);
}