29 lines
734 B
Dart
29 lines
734 B
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||
|
import 'package:kalodings/food_entry_bloc.dart';
|
||
|
import 'package:kalodings/row_with_spacers_widget.dart';
|
||
|
|
||
|
class SumWidget extends StatelessWidget {
|
||
|
const SumWidget({super.key});
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return BlocBuilder<FoodEntryBloc, FoodEntryState>(
|
||
|
builder: (context, state) {
|
||
|
var sum = 0.0;
|
||
|
for (var entry in state.foodEntries) {
|
||
|
sum += entry.kcalPerMass / 100 * entry.mass;
|
||
|
}
|
||
|
|
||
|
return RowWidgetWithSpacers(
|
||
|
null,
|
||
|
null,
|
||
|
const Text("kcal heute:"),
|
||
|
Text(sum.toString()),
|
||
|
null,
|
||
|
);
|
||
|
},
|
||
|
);
|
||
|
}
|
||
|
}
|