design change
parent
b49af31d2c
commit
f325e27f8b
|
@ -35,13 +35,6 @@ class MyCustomFormState extends StatelessWidget with InputValidationMixin {
|
||||||
final _controllerEndSpeed = TextEditingController();
|
final _controllerEndSpeed = TextEditingController();
|
||||||
final _controllerWeight = TextEditingController();
|
final _controllerWeight = TextEditingController();
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_controllerStartSpeed.dispose();
|
|
||||||
_controllerEndSpeed.dispose();
|
|
||||||
_controllerWeight.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _changeJoule(BuildContext context) {
|
void _changeJoule(BuildContext context) {
|
||||||
Provider.of<ResultModel>(context, listen: false).changeJoule(
|
Provider.of<ResultModel>(context, listen: false).changeJoule(
|
||||||
double.parse(_controllerWeight.text),
|
double.parse(_controllerWeight.text),
|
||||||
|
@ -121,19 +114,27 @@ class MyCustomFormState extends StatelessWidget with InputValidationMixin {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text('$_joule Joule \n'
|
FittedBox(
|
||||||
'$_energyWater Liter Wasser können damit erhitzt werden \n'
|
child: Text(
|
||||||
'$_energyIron kg Eisen können damit zu glühen gebracht werden'),
|
'$_joule Joule \n'
|
||||||
|
'$_energyWater Liter Wasser können damit erhitzt werden \n'
|
||||||
|
'$_energyIron kg Eisen können damit zu glühen gebracht werden',
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 20.0,
|
||||||
|
color: Colors.black,
|
||||||
|
))),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
if (formGlobalKey.currentState!.validate()) {
|
if (formGlobalKey.currentState!.validate())
|
||||||
formGlobalKey.currentState!.save()
|
{formGlobalKey.currentState!.save()},
|
||||||
},
|
|
||||||
_changeJoule(context),
|
_changeJoule(context),
|
||||||
},
|
},
|
||||||
child: const Text('Submit'),
|
child: Text('Submit',
|
||||||
|
style: new TextStyle(
|
||||||
|
fontSize: 20.0,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -143,5 +144,6 @@ class MyCustomFormState extends StatelessWidget with InputValidationMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin InputValidationMixin {
|
mixin InputValidationMixin {
|
||||||
bool isInputValid(String value) => !new RegExp(r'[0-9]+.?[0-9]*').hasMatch(value);
|
bool isInputValid(String value) =>
|
||||||
|
!new RegExp(r'[0-9]+.?[0-9]*').hasMatch(value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue