Flutter-Ernaehrungsapp/lib/android/components/food_list_component.dart

34 lines
1.0 KiB
Dart

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) {
return ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: box.keys.length,
itemBuilder: (context, i) {
return CardComponent(
eatingMealName: box.keyAt(i).toString(),
selectedMeal: castDynamicToListFood(box.getAt(i)),
addButtonVisible: box.name != StatisticsService.instance.todayStatisticsBoxName.toLowerCase(),
);
}
);
});
}
}