import 'package:ernaehrung/android/config/cast_helper.dart'; import 'package:ernaehrung/android/config/statistics.dart'; import 'package:flutter/cupertino.dart'; import 'package:hive_flutter/adapters.dart'; import 'card_component.dart'; class FoodComponent extends StatelessWidget { final Box box; const FoodComponent({super.key, required this.box}); @override Widget build(BuildContext context) { return ValueListenableBuilder( valueListenable: box.listenable(), builder: (context, box, widget) { final mealTypes = ['FRÜHSTÜCK','MITTAGESSEN','ABENDESSEN']; // Specify the desired orde return ListView.builder( primary: false, shrinkWrap: true, itemCount: box.keys.length, itemBuilder: (context, i) { return CardComponent( eatingMealName: mealTypes[i], selectedMeal: castDynamicToListFood(box.get(mealTypes[i])), addButtonVisible: box.name != StatisticsService.instance.todayStatisticsBoxName.toLowerCase(), ); } ); }); } }