Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman-Pinjara committed Apr 29, 2023
1 parent afbbe81 commit f569219
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 0 additions & 2 deletions lib/Model/prediction.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ffi';

class PredictionModel {
final int prediction;
final Map<String, dynamic> data;
Expand Down
25 changes: 20 additions & 5 deletions lib/Pages/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ class _InputPageState extends State<InputPage> {
late TextEditingController _mchcontroller;
late TextEditingController _mchccontroller;
late TextEditingController _mcvcontroller;
final _focusNode1 = FocusNode();
final _focusNode2 = FocusNode();
final _focusNode3 = FocusNode();
final _focusNode4 = FocusNode();

void unfocus() {
_focusNode1.unfocus();
_focusNode2.unfocus();
_focusNode3.unfocus();
_focusNode4.unfocus();
}

@override
void initState() {
Expand Down Expand Up @@ -89,10 +100,10 @@ class _InputPageState extends State<InputPage> {
],
),
),
myTextField(_hemocontroller, 'Hemoglobin'),
myTextField(_mchcontroller, 'MCH'),
myTextField(_mchccontroller, 'MCHC'),
myTextField(_mcvcontroller, 'MCV'),
myTextField(_hemocontroller, 'Hemoglobin', _focusNode1),
myTextField(_mchcontroller, 'MCH', _focusNode2),
myTextField(_mchccontroller, 'MCHC', _focusNode3),
myTextField(_mcvcontroller, 'MCV', done: true, _focusNode4),
SizedBox(height: 50),
ElevatedButton(
style: ButtonStyle(
Expand All @@ -101,6 +112,7 @@ class _InputPageState extends State<InputPage> {
backgroundColor: MaterialStateProperty.all(Colors.blueAccent),
),
onPressed: () {
unfocus();
Navigator.push(
context,
MaterialPageRoute(
Expand All @@ -125,11 +137,14 @@ class _InputPageState extends State<InputPage> {
);
}

Widget myTextField(TextEditingController controller, String hint,
Widget myTextField(
TextEditingController controller, String hint, FocusNode focusnode,
{bool done = false}) {
return Padding(
padding: const EdgeInsets.all(12.0),
child: TextFormField(
focusNode: focusnode,
keyboardType: TextInputType.number,
textInputAction: done ? TextInputAction.done : TextInputAction.next,
controller: controller,
decoration: InputDecoration(
Expand Down
5 changes: 4 additions & 1 deletion lib/Pages/prediction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:io';
import 'package:diseaseapp/Model/prediction.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:fluttertoast/fluttertoast.dart';
import 'package:http_parser/http_parser.dart';

class PredictionPage extends StatefulWidget {
Expand Down Expand Up @@ -38,16 +39,18 @@ class _PredictionPageState extends State<PredictionPage> {
final response = await req.send();
if (response.statusCode == 200) {
final res = json.decode(await response.stream.bytesToString());
Fluttertoast.showToast(msg: "Success");
print("Success");
print(res);
return PredictionModel.fromJson(res);
} else {
Fluttertoast.showToast(msg: "API Failed", backgroundColor: Colors.red);
print("Failed");
}
return PredictionModel(
prediction: 1,
data: {
"MCV":"100",
"MCV": "100",
},
);
// return await Future.delayed(const Duration(seconds: 5), () {
Expand Down

0 comments on commit f569219

Please sign in to comment.