cpd_2022_energy/lib/widgets/OutputWidget.dart

63 lines
2.0 KiB
Dart

import 'package:energy/models/CalculateModels.dart';
import 'package:energy/widgets/OutputFieldWidget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class EnergyDisplay extends StatelessWidget {
const EnergyDisplay({super.key});
@override
Widget build(BuildContext context) {
return Column(children: [
const SizedBox(height: 10),
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Consumer<CalculateModels>(builder: (context, model, child) {
return TabDisplayWidget(
"Wasser, das von 20 °C zum Kochen gebracht werden kann:",
double.parse(
(model.amountOfBoilingWaterInL).toStringAsFixed(2)),
"Liter");
}),
],
),
const SizedBox(height: 10),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Consumer<CalculateModels>(builder: (context, model, child) {
return TabDisplayWidget(
"Eisen, das von 20 °C zum Glühen gebracht werden kann:",
double.parse((model.amountOfGlowingIronInKg).toStringAsFixed(2)),
"Kilo");
}),
],
),
const SizedBox(height: 10),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Consumer<CalculateModels>(builder: (context, model, child) {
return TabDisplayWidget(
"Generierte potentielle Energie:",
model.potentialEnergy,
"Joule");
}),
const SizedBox(width: 5),
Consumer<CalculateModels>(builder: (context, model, child) {
return TabDisplayWidget(
"Generierte kinetische Energie:",
model.kineticEnergy,
"Joule");
}),
],
),
const SizedBox(height: 10),
]);
}
}