From fe83b91602dae19d5d98d192ef4e1aaab18a6077 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 17 Aug 2021 14:58:10 +0300 Subject: [PATCH] body fat texfield fix --- .../health_calculator/body_fat/body_fat.dart | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 7f0d0c5c..44a3dc9e 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -50,6 +50,15 @@ class _BodyFatState extends State { TextEditingController waistController = TextEditingController(); TextEditingController hipController = TextEditingController(); + @override + void initState() { + neckController.text = neck.toString(); + hipController.text = hip.toString(); + waistController.text = waist.toString(); + heightController.text = heightCm.toString(); + super.initState(); + } + void updateColorHeight(int type) { //MG/DLT card if (type == 1) { @@ -319,11 +328,6 @@ class _BodyFatState extends State { child: TextFormField( keyboardType: TextInputType.number, controller: heightController, - decoration: InputDecoration( - labelText: heightCm.toString(), - labelStyle: TextStyle( - color: Colors.black, - )), ), ), ), @@ -350,6 +354,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (heightCm < 250) heightCm++; + heightController.text = heightCm.toString(); }); }, ), @@ -362,6 +367,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (heightCm > 0) heightCm--; + heightController.text = heightCm.toString(); }); }, ), @@ -381,6 +387,7 @@ class _BodyFatState extends State { onChanged: (double newValue) { setState(() { heightCm = newValue.round(); + heightController.text = heightCm.toString(); }); }, activeColor: Color(0xffC5272D), @@ -492,15 +499,10 @@ class _BodyFatState extends State { Expanded( child: Center( child: Padding( - padding: const EdgeInsets.only(left: 10.0), + padding: const EdgeInsets.only(left: 15.0, bottom: 0), child: TextFormField( keyboardType: TextInputType.number, controller: neckController, - decoration: InputDecoration( - labelText: neck.toString(), - labelStyle: TextStyle( - color: Colors.black, - )), ), ), ), @@ -527,6 +529,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (neck < 60) neck++; + neckController.text = neck.toString(); }); }, ), @@ -539,6 +542,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (neck > 5) neck--; + neckController.text = neck.toString(); }); }, ), @@ -558,6 +562,7 @@ class _BodyFatState extends State { onChanged: (double newValue) { setState(() { neck = newValue.round(); + neckController.text = neck.toString(); }); }, activeColor: Color(0xffC5272D), @@ -673,11 +678,6 @@ class _BodyFatState extends State { child: TextFormField( keyboardType: TextInputType.number, controller: waistController, - decoration: InputDecoration( - labelText: waist.toString(), - labelStyle: TextStyle( - color: Colors.black, - )), ), ), ), @@ -704,6 +704,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (waist < 200) waist++; + waistController.text = waist.toString(); }); }, ), @@ -716,6 +717,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (waist > 5) waist--; + waistController.text = waist.toString(); }); }, ), @@ -735,6 +737,7 @@ class _BodyFatState extends State { onChanged: (double newValue) { setState(() { waist = newValue.round(); + waistController.text = waist.toString(); }); }, activeColor: Color(0xffC5272D), @@ -850,11 +853,6 @@ class _BodyFatState extends State { child: TextFormField( keyboardType: TextInputType.number, controller: hipController, - decoration: InputDecoration( - labelText: hip.toString(), - labelStyle: TextStyle( - color: Colors.black, - )), ), ), ), @@ -881,6 +879,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (hip < 140) hip++; + hipController.text = hip.toString(); }); }, ), @@ -893,6 +892,7 @@ class _BodyFatState extends State { onTap: () { setState(() { if (hip > 5) hip--; + hipController.text = hip.toString(); }); }, ), @@ -912,6 +912,7 @@ class _BodyFatState extends State { onChanged: (double newValue) { setState(() { hip = newValue.round(); + hipController.text = hip.toString(); }); }, activeColor: Color(0xffC5272D),