handeling error in patients list
parent
0799c74957
commit
046ef17b21
@ -1,40 +1,60 @@
|
||||
import 'package:doctor_app_flutter/models/patient_model.dart';
|
||||
import 'package:doctor_app_flutter/providers/patients_provider.dart';
|
||||
import '../../models/patient_model.dart';
|
||||
import '../../providers/patients_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientsList extends StatefulWidget {
|
||||
@override
|
||||
_PatientsListState createState() => _PatientsListState();
|
||||
}
|
||||
|
||||
class _PatientsListState extends State<PatientsList> {
|
||||
var _isInit =true;
|
||||
var _isInit = true;
|
||||
var _isLoading = true;
|
||||
var _hasError;
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
|
||||
PatientModel patient = routeArgs['patientSearchForm'];
|
||||
String patientType = routeArgs['selectedType'];
|
||||
print(patientType);
|
||||
if(_isInit) {
|
||||
if (_isInit) {
|
||||
// setState(() {});
|
||||
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
|
||||
patientsProv.getPatientList(patient, patientType).then((res) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_hasError = res['ErrorEndUserMessage'];
|
||||
|
||||
});
|
||||
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
|
||||
patientsProv.getPatientList(patient, patientType).then((res){
|
||||
print('Response EEEEEEEE: ${res}');
|
||||
print(res['ServiceName']);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
}
|
||||
_isInit = false;
|
||||
super.didChangeDependencies();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text('PatientsList'),),
|
||||
appBar: AppBar(
|
||||
title: Text('PatientsList'),
|
||||
),
|
||||
body: _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Container(
|
||||
child: _hasError != null
|
||||
? Center(
|
||||
child: Text(
|
||||
_hasError,
|
||||
style: TextStyle(color: Theme.of(context).errorColor),
|
||||
),
|
||||
)
|
||||
: Text('EEEEEEEEEEEEEE'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue