calorimeter/lib/enter_food_widget.dart

52 lines
1.5 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:kalodings/food_entry_bloc.dart';
class EnterFoodWidget extends StatefulWidget {
const EnterFoodWidget({
super.key,
});
@override
State<EnterFoodWidget> createState() => _EnterFoodWidgetState();
}
class _EnterFoodWidgetState extends State<EnterFoodWidget> {
String perFoodresult = "dings";
@override
Widget build(BuildContext context) {
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Spacer(flex: 1),
const Expanded(
flex: 4,
child:
TextField(decoration: InputDecoration(hintText: "Name"))),
const Expanded(
flex: 4,
child:
TextField(decoration: InputDecoration(hintText: "Menge"))),
const Expanded(
flex: 4,
child: TextField(
decoration: InputDecoration(hintText: "kcal pro 100g")),
),
Text(perFoodresult),
const Spacer(flex: 1),
],
),
ElevatedButton(
child: const Text("Hinzufügen"),
onPressed: () {
var entry =
FoodEntry(name: '', mass: 2.0, kcal: 100, kcalPerMass: 200);
context.read<FoodEntryBloc>().add(FoodEntryEvent(entry: entry));
}),
],
);
}
}