fix the calling api

merge-requests/1/merge
Elham Rababah 6 years ago
parent be68e065a3
commit 0799c74957

@ -6,7 +6,7 @@ import 'package:http/http.dart' as http;
import 'dart:convert'; import 'dart:convert';
class PatientsProvider with ChangeNotifier { class PatientsProvider with ChangeNotifier {
Future<void> getPatientList(PatientModel patient, patientType) async { Future<Map> getPatientList(PatientModel patient, patientType) async {
Map<String, String> requestHeaders = { Map<String, String> requestHeaders = {
'Content-type': 'application/json', 'Content-type': 'application/json',
'Accept': 'application/json', 'Accept': 'application/json',
@ -41,6 +41,7 @@ class PatientsProvider with ChangeNotifier {
// var response = await http.post(url, body: {'name': 'doodle', 'color': 'blue'}); // var response = await http.post(url, body: {'name': 'doodle', 'color': 'blue'});
print('Response status: ${response.statusCode}'); print('Response status: ${response.statusCode}');
print('Response body: ${response.body}'); print('Response body: ${response.body}');
return Future.value(json.decode(response.body));
notifyListeners(); notifyListeners();
} catch (error) { } catch (error) {
print(error.toString()); print(error.toString());

@ -8,16 +8,31 @@ class PatientsList extends StatefulWidget {
} }
class _PatientsListState extends State<PatientsList> { class _PatientsListState extends State<PatientsList> {
@override var _isInit =true;
Widget build(BuildContext context) { @override
void didChangeDependencies() {
final routeArgs = ModalRoute.of(context).settings.arguments as Map; final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatientModel patient = routeArgs['patientSearchForm']; PatientModel patient = routeArgs['patientSearchForm'];
String patientType = routeArgs['selectedType']; String patientType = routeArgs['selectedType'];
print(patientType); print(patientType);
var list ; if(_isInit) {
setState(() {
});
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context); PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
patientsProv.getPatientList(patient, patientType); patientsProv.getPatientList(patient, patientType).then((res){
print('Response EEEEEEEE: ${res}');
print(res['ServiceName']);
});
}
_isInit = false;
super.didChangeDependencies();
}
@override
Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text('PatientsList'),), appBar: AppBar(title: Text('PatientsList'),),
); );

Loading…
Cancel
Save