94 lines
2.7 KiB
Dart
94 lines
2.7 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
import 'package:cpd_2022_energy/variables.dart';
|
||
|
import 'package:provider/provider.dart';
|
||
|
|
||
|
class InputForm extends StatelessWidget {
|
||
|
const InputForm({super.key});
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
double _startH = 0;
|
||
|
double _endH = 0;
|
||
|
double _startG = 0;
|
||
|
double _endG = 0;
|
||
|
double _masse = 0;
|
||
|
|
||
|
final formKey = GlobalKey<FormState>();
|
||
|
final data = Provider.of<variables>(context);
|
||
|
|
||
|
// wird bei onPressed mit Button ausgelöst
|
||
|
void _anzeigen() {
|
||
|
data.setStartH(_startH);
|
||
|
data.setEndH(_endH);
|
||
|
data.setStartGes(_startG);
|
||
|
data.setEndGes(_endG);
|
||
|
data.setMasse(_masse);
|
||
|
}
|
||
|
|
||
|
return Container(
|
||
|
padding: EdgeInsets.symmetric(vertical: 20, horizontal: 30),
|
||
|
child: Form(
|
||
|
key: formKey,
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||
|
children: <Widget>[
|
||
|
TextFormField(
|
||
|
decoration: const InputDecoration(
|
||
|
labelText: 'Starthöhe',
|
||
|
hintText: 'in Meter',
|
||
|
),
|
||
|
onChanged: (eingabe) {
|
||
|
_startH = eingabe as double;
|
||
|
},
|
||
|
),
|
||
|
TextFormField(
|
||
|
decoration: const InputDecoration(
|
||
|
labelText: 'Endhöhe',
|
||
|
hintText: 'in Meter',
|
||
|
),
|
||
|
onChanged: (eingabe) {
|
||
|
_endH = double.parse(eingabe);
|
||
|
},
|
||
|
),
|
||
|
TextFormField(
|
||
|
decoration: const InputDecoration(
|
||
|
labelText: 'Startgeschwindigkeit',
|
||
|
hintText: 'in Meter pro Sekunde',
|
||
|
),
|
||
|
onChanged: (eingabe) {
|
||
|
_startG = double.parse(eingabe);
|
||
|
},
|
||
|
),
|
||
|
TextFormField(
|
||
|
decoration: const InputDecoration(
|
||
|
labelText: 'Endgeschwindigkeit',
|
||
|
hintText: 'in Meter pro Sekunde',
|
||
|
),
|
||
|
onChanged: (eingabe) {
|
||
|
_endG = double.parse(eingabe);
|
||
|
},
|
||
|
),
|
||
|
TextFormField(
|
||
|
decoration: const InputDecoration(
|
||
|
labelText: 'Masse',
|
||
|
hintText: 'in KG',
|
||
|
),
|
||
|
onChanged: (eingabe) {
|
||
|
_masse = double.parse(eingabe);
|
||
|
},
|
||
|
),
|
||
|
TextButton(
|
||
|
onPressed: () => _anzeigen(),
|
||
|
child: Text('Berechnen'),
|
||
|
style: TextButton.styleFrom(
|
||
|
foregroundColor: Colors.white,
|
||
|
backgroundColor: Colors.green,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|