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

34 lines
1.0 KiB
Dart
Raw Normal View History

import 'package:ernaehrung/android/config/cast_helper.dart';
2023-06-01 12:14:23 +02:00
import 'package:ernaehrung/android/config/statistics.dart';
2023-05-29 12:08:46 +02:00
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});
2023-05-29 12:08:46 +02:00
@override
Widget build(BuildContext context) {
2023-05-29 12:08:46 +02:00
return ValueListenableBuilder(
valueListenable: box.listenable(),
2023-05-29 12:08:46 +02:00
builder: (context, box, widget) {
return ListView.builder(
primary: false,
shrinkWrap: true,
itemCount: box.keys.length,
itemBuilder: (context, i) {
2023-06-16 11:44:42 +02:00
return CardComponent(
eatingMealName: box.keyAt(i).toString(),
selectedMeal: castDynamicToListFood(box.getAt(i)),
addButtonVisible: box.name != StatisticsService.instance.todayStatisticsBoxName.toLowerCase(),
);
}
);
2023-05-29 12:08:46 +02:00
});
}
2023-05-29 12:08:46 +02:00
}