|
| 1 | +import 'package:health_check_app/Resources/RoundedButton.dart'; |
| 2 | +import 'package:health_check_app/Resources/TextformField.dart'; |
| 3 | +import 'package:flutter/material.dart'; |
| 4 | + |
| 5 | +class HeartAttack extends StatefulWidget { |
| 6 | + @override |
| 7 | + _HeartAttackState createState() => _HeartAttackState(); |
| 8 | +} |
| 9 | + |
| 10 | +class _HeartAttackState extends State<HeartAttack> { |
| 11 | + final _formKey = GlobalKey<FormState>(); |
| 12 | + |
| 13 | + double age, trestbps, chol, thalach, oldpeak, slope; |
| 14 | + String select; |
| 15 | + |
| 16 | + Row addRadioButton(int btnValue, String title) { |
| 17 | + return Row( |
| 18 | + mainAxisAlignment: MainAxisAlignment.start, |
| 19 | + children: <Widget>[ |
| 20 | + Radio( |
| 21 | + activeColor: Theme.of(context).primaryColor, |
| 22 | + value: btnValue, |
| 23 | + groupValue: select, |
| 24 | + onChanged: (value) { |
| 25 | + setState(() { |
| 26 | + print(value); |
| 27 | + select = value; |
| 28 | + }); |
| 29 | + }, |
| 30 | + ), |
| 31 | + Text(title) |
| 32 | + ], |
| 33 | + ); |
| 34 | + } |
| 35 | + |
| 36 | + @override |
| 37 | + Widget build(BuildContext context) { |
| 38 | + return Scaffold( |
| 39 | + body: SafeArea( |
| 40 | + child: SingleChildScrollView( |
| 41 | + scrollDirection: Axis.vertical, |
| 42 | + child: Center( |
| 43 | + child: Column( |
| 44 | + children: [ |
| 45 | + Padding( |
| 46 | + padding: const EdgeInsets.only( |
| 47 | + top: 20.0, left: 10.0, right: 10.0), |
| 48 | + child: Column( |
| 49 | + children: [ |
| 50 | + Row( |
| 51 | + mainAxisAlignment: MainAxisAlignment.center, |
| 52 | + children: [ |
| 53 | + Text( |
| 54 | + 'Heart Attack', |
| 55 | + style: TextStyle( |
| 56 | + fontSize: 35.0, fontFamily: 'Langar'), |
| 57 | + ), |
| 58 | + ]), |
| 59 | + Row( |
| 60 | + mainAxisAlignment: MainAxisAlignment.center, |
| 61 | + children: [ |
| 62 | + Text( |
| 63 | + 'Detection', |
| 64 | + style: TextStyle( |
| 65 | + fontSize: 35.0, fontFamily: 'Langar'), |
| 66 | + ), |
| 67 | + ]), |
| 68 | + ], |
| 69 | + )), |
| 70 | + SizedBox( |
| 71 | + height: 20, |
| 72 | + child: Divider( |
| 73 | + color: Colors.white, |
| 74 | + thickness: 0.8, |
| 75 | + ), |
| 76 | + width: 350, |
| 77 | + ), |
| 78 | + Padding( |
| 79 | + padding: |
| 80 | + const EdgeInsets.only(top: 20.0, left: 10.0, right: 10.0), |
| 81 | + child: Form( |
| 82 | + key: _formKey, |
| 83 | + child: Column( |
| 84 | + children: [ |
| 85 | + Row( |
| 86 | + children: [ |
| 87 | + Text('Enter the following details', |
| 88 | + style: TextStyle( |
| 89 | + fontSize: 20.0, fontFamily: 'Langar')), |
| 90 | + ], |
| 91 | + ), |
| 92 | + SizedBox( |
| 93 | + height: 20, |
| 94 | + ), |
| 95 | + TextFField( |
| 96 | + hintText: 'Age', |
| 97 | + onChanged: (value) { |
| 98 | + value = age.toString(); |
| 99 | + }, |
| 100 | + validator: (val) { |
| 101 | + if (val.isEmpty || val == null) { |
| 102 | + return 'Please enter value'; |
| 103 | + } else { |
| 104 | + age = double.parse(val); |
| 105 | + } |
| 106 | + }, |
| 107 | + ), |
| 108 | + SizedBox( |
| 109 | + height: 20, |
| 110 | + ), |
| 111 | + Text( |
| 112 | + 'Gender', |
| 113 | + style: TextStyle(fontSize: 20.0), |
| 114 | + ), |
| 115 | + Wrap( |
| 116 | + children: [ |
| 117 | + addRadioButton(1, "Male"), |
| 118 | + addRadioButton(0, "Female"), |
| 119 | + ], |
| 120 | + ), |
| 121 | + SizedBox( |
| 122 | + height: 20, |
| 123 | + ), |
| 124 | + Text( |
| 125 | + 'Chest Pain Type', |
| 126 | + style: TextStyle(fontSize: 20.0), |
| 127 | + ), |
| 128 | + Wrap( |
| 129 | + children: [ |
| 130 | + addRadioButton(0, "0"), |
| 131 | + addRadioButton(1, "1"), |
| 132 | + addRadioButton(2, "2"), |
| 133 | + addRadioButton(3, "3"), |
| 134 | + ], |
| 135 | + ), |
| 136 | + SizedBox( |
| 137 | + height: 20, |
| 138 | + ), |
| 139 | + TextFField( |
| 140 | + hintText: 'Resting Blood Pressure', |
| 141 | + onChanged: (value) { |
| 142 | + value = trestbps.toString(); |
| 143 | + }, |
| 144 | + validator: (val) { |
| 145 | + if (val.isEmpty || val == null) { |
| 146 | + return 'Please enter value'; |
| 147 | + } else { |
| 148 | + trestbps = double.parse(val); |
| 149 | + } |
| 150 | + }, |
| 151 | + ), |
| 152 | + SizedBox( |
| 153 | + height: 20, |
| 154 | + ), |
| 155 | + TextFField( |
| 156 | + hintText: 'Serum Cholestoral (mg/dl)', |
| 157 | + onChanged: (value) { |
| 158 | + value = chol.toString(); |
| 159 | + }, |
| 160 | + validator: (val) { |
| 161 | + if (val.isEmpty || val == null) { |
| 162 | + return 'Please enter value'; |
| 163 | + } else { |
| 164 | + chol = double.parse(val); |
| 165 | + } |
| 166 | + }, |
| 167 | + ), |
| 168 | + SizedBox( |
| 169 | + height: 20, |
| 170 | + ), |
| 171 | + Text( |
| 172 | + 'Fasting Blood Sugar', |
| 173 | + style: TextStyle(fontSize: 20.0), |
| 174 | + ), |
| 175 | + Wrap( |
| 176 | + children: [ |
| 177 | + addRadioButton(1, ">120 mg/dl"), |
| 178 | + addRadioButton(0, "<120 mg/dl"), |
| 179 | + ], |
| 180 | + ), |
| 181 | + SizedBox( |
| 182 | + height: 20, |
| 183 | + ), |
| 184 | + Text( |
| 185 | + 'Resting Electrocardiographic Results', |
| 186 | + style: TextStyle(fontSize: 20.0), |
| 187 | + ), |
| 188 | + Wrap( |
| 189 | + children: [ |
| 190 | + addRadioButton(0, "0"), |
| 191 | + addRadioButton(1, "1"), |
| 192 | + addRadioButton(2, "2"), |
| 193 | + ], |
| 194 | + ), |
| 195 | + SizedBox( |
| 196 | + height: 20, |
| 197 | + ), |
| 198 | + TextFField( |
| 199 | + hintText: 'Maximum Heart Rate Achieved', |
| 200 | + onChanged: (value) { |
| 201 | + value = thalach.toString(); |
| 202 | + }, |
| 203 | + validator: (val) { |
| 204 | + if (val.isEmpty || val == null) { |
| 205 | + return 'Please enter value'; |
| 206 | + } else { |
| 207 | + thalach = double.parse(val); |
| 208 | + } |
| 209 | + }, |
| 210 | + ), |
| 211 | + SizedBox( |
| 212 | + height: 20, |
| 213 | + ), |
| 214 | + Text( |
| 215 | + 'Exercise Induced Angina', |
| 216 | + style: TextStyle(fontSize: 20.0), |
| 217 | + ), |
| 218 | + Wrap( |
| 219 | + children: [ |
| 220 | + addRadioButton(1, "1"), |
| 221 | + addRadioButton(0, "0"), |
| 222 | + ], |
| 223 | + ), |
| 224 | + SizedBox( |
| 225 | + height: 20, |
| 226 | + ), |
| 227 | + TextFField( |
| 228 | + hintText: 'ST Depression Induced by Exercise', |
| 229 | + onChanged: (value) { |
| 230 | + value = oldpeak.toString(); |
| 231 | + }, |
| 232 | + validator: (val) { |
| 233 | + if (val.isEmpty || val == null) { |
| 234 | + return 'Please enter value'; |
| 235 | + } else { |
| 236 | + oldpeak = double.parse(val); |
| 237 | + } |
| 238 | + }, |
| 239 | + ), |
| 240 | + SizedBox( |
| 241 | + height: 20, |
| 242 | + ), |
| 243 | + TextFField( |
| 244 | + hintText: ' Slope of the Peak Exercise ST Segment', |
| 245 | + onChanged: (value) { |
| 246 | + value = slope.toString(); |
| 247 | + }, |
| 248 | + validator: (val) { |
| 249 | + if (val.isEmpty || val == null) { |
| 250 | + return 'Please enter value'; |
| 251 | + } else { |
| 252 | + slope = double.parse(val); |
| 253 | + } |
| 254 | + }, |
| 255 | + ), |
| 256 | + SizedBox( |
| 257 | + height: 20, |
| 258 | + ), |
| 259 | + Text( |
| 260 | + 'Number of Major Vessels', |
| 261 | + style: TextStyle(fontSize: 20.0), |
| 262 | + ), |
| 263 | + Wrap( |
| 264 | + children: [ |
| 265 | + addRadioButton(0, "0"), |
| 266 | + addRadioButton(1, "1"), |
| 267 | + addRadioButton(2, "2"), |
| 268 | + addRadioButton(3, "3"), |
| 269 | + ], |
| 270 | + ), |
| 271 | + SizedBox( |
| 272 | + height: 20, |
| 273 | + ), |
| 274 | + Text( |
| 275 | + 'Thal', |
| 276 | + style: TextStyle(fontSize: 20.0), |
| 277 | + ), |
| 278 | + Wrap( |
| 279 | + children: [ |
| 280 | + addRadioButton(0, "Normal"), |
| 281 | + addRadioButton(1, "Fixed Defect"), |
| 282 | + addRadioButton(2, "Reversable Defect"), |
| 283 | + ], |
| 284 | + ), |
| 285 | + SizedBox( |
| 286 | + height: 20, |
| 287 | + ), |
| 288 | + RoundedButton( |
| 289 | + color: Colors.orangeAccent, |
| 290 | + text: 'Submit', |
| 291 | + press: () { |
| 292 | + if (_formKey.currentState.validate()) { |
| 293 | + ScaffoldMessenger.of(context).showSnackBar( |
| 294 | + SnackBar(content: Text('Processing Data'))); |
| 295 | + } |
| 296 | + }, |
| 297 | + ), |
| 298 | + ], |
| 299 | + ), |
| 300 | + ), |
| 301 | + ) |
| 302 | + ], |
| 303 | + ), |
| 304 | + ), |
| 305 | + ), |
| 306 | + ), |
| 307 | + ); |
| 308 | + } |
| 309 | +} |
0 commit comments