Last active
September 9, 2021 08:36
-
-
Save Roy-Tuhin/85dae5e908b21c92cb19a7f3c82dc0e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//And depending upon Lab my Test response | |
{ | |
"Status": "1", | |
"Message": "", | |
"Data": [ | |
{ | |
"TestId": "I3uXyzcuDZf21SSe5fHnSQ==", | |
"EncTestId": null, | |
"TestName": "RT-PCR", | |
"NoOfPartner": null, | |
"TestFee": null, | |
"DiscountedFee": null, | |
"BookingFee": null, | |
"ReportTime": null, | |
"Note": null, | |
"CreateBy": null, | |
"CreateDate": null, | |
"ModBy": null, | |
"ModDate": null, | |
"ActiveStatus": null, | |
"Permission": null | |
}, | |
{ | |
"TestId": "I3uXyzcuDZf21SSe5fHnSQ==", | |
"EncTestId": null, | |
"TestName": "RT-PCR", | |
"NoOfPartner": null, | |
"TestFee": null, | |
"DiscountedFee": null, | |
"BookingFee": null, | |
"ReportTime": null, | |
"Note": null, | |
"CreateBy": null, | |
"CreateDate": null, | |
"ModBy": null, | |
"ModDate": null, | |
"ActiveStatus": null, | |
"Permission": null | |
}, | |
{ | |
"TestId": "I3uXyzcuDZf21SSe5fHnSQ==", | |
"EncTestId": null, | |
"TestName": "RT-PCR", | |
"NoOfPartner": null, | |
"TestFee": null, | |
"DiscountedFee": null, | |
"BookingFee": null, | |
"ReportTime": null, | |
"Note": null, | |
"CreateBy": null, | |
"CreateDate": null, | |
"ModBy": null, | |
"ModDate": null, | |
"ActiveStatus": null, | |
"Permission": null | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Status": "1", | |
"Message": "", | |
"Partner": [ | |
{ | |
"EncPartnerId": "IujyQXg8KZg8asLvK/FS7g==", | |
"PartnerName": "dasfdsf" | |
}, | |
{ | |
"EncPartnerId": "pEl2B9kuumKRxIxLJO76eQ==", | |
"PartnerName": "partner172" | |
}, | |
{ | |
"EncPartnerId": "eYwtNBXR6P/JDtsIwr+Bvw==", | |
"PartnerName": "nnkb" | |
}, | |
{ | |
"EncPartnerId": "kFgorcFF0G6RQD4W+LwWnQ==", | |
"PartnerName": "nnkjj" | |
}, | |
{ | |
"EncPartnerId": "U4exk+vfMGrn7cjNUa/PBw==", | |
"PartnerName": "mahadev" | |
}, | |
{ | |
"EncPartnerId": "tqkaSjTFgDf0612mp9mbsQ==", | |
"PartnerName": null | |
}, | |
{ | |
"EncPartnerId": "0aruO0FbYOu5IerRBxdT8w==", | |
"PartnerName": "Suraksha Diagnostics" | |
}, | |
{ | |
"EncPartnerId": "65gtodyhbtdInTsJWr1ZkA==", | |
"PartnerName": "Rasomoy pvt. Hospital" | |
}, | |
{ | |
"EncPartnerId": "LEuT1eIlpLEMAAkZme3wpQ==", | |
"PartnerName": "Tangra medical House" | |
}, | |
{ | |
"EncPartnerId": "q8O8YMzYKXSB4RtkX4k7Lw==", | |
"PartnerName": "Partner new" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'package:date_time_picker/date_time_picker.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:medbo/models/allSurgicalPackModels.dart'; | |
import 'AllPathLabTestModel.dart'; | |
import 'package:http/http.dart' as http; | |
import 'Dependent_DropDown_in_MultipleTest_Model.dart'; | |
class MultipleTestBooking extends StatefulWidget { | |
const MultipleTestBooking({Key? key}) : super(key: key); | |
@override | |
_MultipleTestBookingState createState() => _MultipleTestBookingState(); | |
} | |
class _MultipleTestBookingState extends State<MultipleTestBooking> { | |
Partner? _selectedLab; | |
Datum? _selectedTest; | |
String encLabId = ''; | |
void initState(){ | |
super.initState(); | |
AllPathLab(); | |
} | |
String _selectedDate = DateTime.now().toString(); | |
final List<String> allLabList = [ | |
"Select Lab", | |
"Abc", | |
"Xyz", | |
]; | |
String selectedLabFromList = "Abc"; | |
@override | |
Widget build(BuildContext context) { | |
var screenWidth = MediaQuery.of(context).size.width; | |
var screenHeight = MediaQuery.of(context).size.height; | |
var blockSizeHorizontal = (screenWidth / 100); | |
var blockSizeVertical = (screenHeight / 100); | |
return Scaffold( | |
body: SafeArea( | |
child: Container( | |
child: Column( | |
children: [ | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: ListTile( | |
title: Text("Booking Information", | |
style: TextStyle( | |
fontWeight: FontWeight.bold, | |
fontSize: blockSizeHorizontal * 5, | |
fontFamily: 'Poppins', | |
color: Theme.of(context).primaryColor, | |
)), | |
subtitle: Text("Preferred Visit Date"), | |
), | |
), | |
//============================================================================== | |
Container( | |
margin: EdgeInsets.only(left: 20), | |
padding: EdgeInsets.only(left: 0, right: 150), | |
decoration: BoxDecoration( | |
// color: Color(0xFF3E64FF), | |
color: Colors.lightBlue[50], | |
borderRadius: BorderRadius.all(Radius.circular(12)), | |
// boxShadow: [ | |
// BoxShadow( | |
// //color: Color(0xFF3E64FF).withOpacity(0.3), | |
// color: Colors.grey.withOpacity(0.9), | |
// offset: const Offset( | |
// 0.0, | |
// 5.0, | |
// ), | |
// blurRadius: 3.0, | |
// spreadRadius: 0.5, | |
// ), | |
// ], | |
), | |
child: Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: DateTimePicker( | |
initialValue: DateTime.now().toString(), | |
//initialValue:'', // initialValue or controller.text can be null, empty or a DateTime string otherwise it will throw an error. | |
type: DateTimePickerType.date, | |
dateLabelText: 'Select Date', | |
style: TextStyle( | |
fontWeight: FontWeight.bold, | |
fontSize: blockSizeHorizontal * 3.5, | |
fontFamily: 'Poppins', | |
color: Colors.green, | |
letterSpacing: 2.0, | |
), | |
firstDate: DateTime.now(), | |
lastDate: DateTime.now().add(Duration( | |
days: 30)), // This will add one year from current date | |
validator: (value) { | |
return null; | |
}, | |
onChanged: (value) { | |
if (value.isNotEmpty) { | |
setState(() { | |
_selectedDate = value; | |
}); | |
} | |
}, | |
onSaved: (value) { | |
if (value.isNotEmpty) { | |
_selectedDate = value; | |
} | |
}, | |
), | |
), | |
), | |
//============================================================================== | |
ListTile( | |
title: Text( | |
"Select Pathological Lab", | |
style: TextStyle( | |
fontWeight: FontWeight.bold, | |
fontSize: blockSizeHorizontal * 4.0, | |
fontFamily: 'Poppins', | |
color: Theme.of(context).primaryColor, | |
), | |
), | |
), | |
Container( | |
child: FutureBuilder<List<Partner>>( | |
future: AllPathLab(), | |
builder: | |
(BuildContext context, AsyncSnapshot snapshot) { | |
if (snapshot.connectionState !=ConnectionState.done) { | |
return CircularProgressIndicator(); | |
} | |
if (snapshot.hasError) { | |
return Text("Somthing went wrong"); | |
} | |
if (snapshot.hasData) { | |
return DropdownButton<Partner>( | |
value: _selectedLab, | |
hint: Text("Select Lab"), | |
//underline: SizedBox(), | |
//isExpanded: true, | |
items: snapshot.data.map((Partner data) => | |
DropdownMenuItem<Partner>( | |
child: Text("${data.partnerName}"), | |
value: data, | |
) | |
).toList().cast<DropdownMenuItem<Partner>>(), | |
onChanged: (value){ | |
setState(() { | |
_selectedLab=value; | |
encLabId = value!.encPartnerId; | |
GetTestByLab(); | |
}); | |
//GetTestByLab(value!.encPartnerId); // passing encid to my next API function | |
// GetTestByLab(); | |
}, | |
); | |
} | |
return Text("Waiting for Internet Connection"); | |
}, | |
), | |
), | |
//=========================================================== Dependent drop down=================================== | |
ListTile( | |
title: Text( | |
"Test Name", | |
style: TextStyle( | |
fontWeight: FontWeight.bold, | |
fontSize: blockSizeHorizontal * 4.0, | |
fontFamily: 'Poppins', | |
color: Theme.of(context).primaryColor, | |
), | |
), | |
), | |
Container( | |
child: FutureBuilder<List<Datum>>( | |
future: GetTestByLab(), | |
builder: | |
(BuildContext context, AsyncSnapshot snapshot) { | |
if (snapshot.connectionState !=ConnectionState.done) { | |
return CircularProgressIndicator(); | |
} | |
if (snapshot.hasError) { | |
return Text("Select a Lab for your Test"); | |
} | |
if (snapshot.hasData) { | |
return DropdownButton<Datum>( | |
value: _selectedTest, | |
hint: Text(""), | |
//underline: SizedBox(), | |
//isExpanded: true, | |
items: snapshot.data.map((Datum data) => | |
DropdownMenuItem<Datum>( | |
child: Text("${data.testName}"), | |
value: data, | |
) | |
).toList().cast<DropdownMenuItem<Datum>>(), | |
onChanged: (value){ | |
_selectedTest=value; | |
//GetTestByLab(value!.encPartnerId); // passing encid to my next API function | |
}); | |
} | |
return Text("Waiting for Internet Connection"); | |
}, | |
), | |
), | |
// ListTile( | |
// title: Text( | |
// " Select Pathological Lab", | |
// style: TextStyle( | |
// fontWeight: FontWeight.bold, | |
// fontSize: blockSizeHorizontal * 4.0, | |
// fontFamily: 'Poppins', | |
// color: Theme.of(context).primaryColor, | |
// ), | |
// ), | |
// ), | |
// Padding( | |
// padding: const EdgeInsets.only(left: 0.0), | |
// child: DropdownButton<String>( | |
// value: selectedLabFromList, | |
// onChanged: (value) { | |
// setState(() { | |
// selectedLabFromList = value!; | |
// }); | |
// }, | |
// items:allLabList.map<DropdownMenuItem<String>>((value) { | |
// return DropdownMenuItem( | |
// child: Text(value), | |
// value: value, | |
// ); | |
// }).toList(), | |
// ), | |
// ), | |
], | |
), | |
), | |
), | |
); | |
} | |
//========================================================================================================================================================================== | |
Future<List<Partner>> AllPathLab() async { | |
var jsonResponse; | |
var response = await http.post(Uri.parse("http://medbo.digitalicon.in/api/medboapi/AllPathLab"), | |
body: ({ | |
})); | |
if (response.statusCode == 200) { | |
print("Correct"); | |
// print(response.body); | |
jsonResponse = json.decode(response.body.toString()); | |
print(jsonResponse); | |
AllPathLabTestModel dataModel = allPathLabTestModelFromJson(response.body); | |
print(dataModel.partner.length); | |
for (final item in dataModel.partner) { | |
print(item.partnerName); | |
} | |
List<Partner> arrData = dataModel.partner; // this "partner" is actual json array of data[] | |
return arrData; | |
} else { | |
print("Wrong URL"); | |
throw Exception("Faild to fetch"); | |
} | |
} | |
//========================================================================================================================================================================== | |
Future<List<Datum>> GetTestByLab() async { | |
var jsonResponse; | |
var response = await http.post(Uri.parse("http://medbo.digitalicon.in/api/medboapi/GetTestByLab"), | |
body: ({ | |
"EncId": encLabId | |
//"EncId": 'I3uXyzcuDZf21SSe5fHnSQ==' | |
})); | |
if (response.statusCode == 200) { | |
print("Correct"); | |
// print(response.body); | |
jsonResponse = json.decode(response.body.toString()); | |
print(jsonResponse); | |
DependentDropDownModel dataModel = dependentDropDownModelFromJson(response.body); | |
print(dataModel.data.length); | |
for (final item in dataModel.data) | |
print(item.testName); | |
// print(item.testId); | |
List<Datum> arrData = dataModel.data; // this "partner" is actual json array of data[] | |
return arrData; | |
} else { | |
print("Wrong URL"); | |
throw Exception("Faild to fetch"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment