import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:hive/hive.dart'; import 'package:hive_flutter/adapters.dart'; import '../config/statistics.dart'; import 'card/card_component.dart'; class MealsComponent extends StatelessWidget { MealsComponent({Key? key}) : super(key: key); final List colors = [Colors.teal,Colors.red,Colors.green]; @override Widget build(BuildContext context) { return ValueListenableBuilder( valueListenable: Hive.box(dotenv.env['MEALPLAN_BOX'] ?? 'MEALPLAN').listenable(), builder: (context, box, widget) { final mealTypes = ['FRÜHSTÜCK','MITTAGESSEN','ABENDESSEN']; // Specify the desired order of meal types return ListView.builder( primary: false, shrinkWrap: true, itemCount: box.keys.length, itemBuilder: (context, i) { String mealTypeAsString = mealTypes[i]; return CardComponent( mealTypeAsString, StatisticsService.instance.getMealsOfTodayByMealtype(mealTypeAsString), color: colors[i], ); }); }); } }