calorimeter/lib/food_entry_widget.dart

30 lines
876 B
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2024-06-09 12:42:17 +00:00
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:kalodings/food_entry_bloc.dart';
import 'package:kalodings/row_with_spacers_widget.dart';
class FoodEntryWidget extends StatelessWidget {
2024-06-09 12:42:17 +00:00
final FoodEntry entry;
2024-06-01 10:41:58 +00:00
2024-06-09 12:42:17 +00:00
const FoodEntryWidget({super.key, required this.entry});
@override
Widget build(BuildContext context) {
2024-06-09 12:42:17 +00:00
return Card(
child: RowWidgetWithSpacers(
Text(entry.name),
Text(entry.mass.toString()),
Text(entry.kcalPerMass.toString()),
Text((entry.mass * entry.kcalPerMass / 100).toString()),
IconButton(
onPressed: () {
context
.read<FoodEntryBloc>()
.add(FoodDeletionEvent(entryID: entry.id));
},
icon: const Icon(Icons.delete_forever_rounded)),
),
);
}
}