import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:flutter/cupertino.dart'; import '../models/list_doctor_working_hours_table_model.dart'; import '../models/request_schedule.dart'; class ScheduleProvider with ChangeNotifier { List listDoctorWorkingHoursTable = []; bool isLoading = true; bool isError = false; String error = ''; RequestSchedule requestSchedule = RequestSchedule(); ScheduleProvider() { getDoctorSchedule(); } getDoctorSchedule() async { try { await BaseAppClient.post('Doctors.svc/REST/GetDoctorWorkingHoursTable', body: requestSchedule.toJson(), onSuccess: (dynamic response, int statusCode) { response['List_DoctorWorkingHoursTable'].forEach((v) { listDoctorWorkingHoursTable.add(new ListDoctorWorkingHoursTable.fromJson(v)); }); isError = false; isLoading = false; }, onFailure: (String error, int statusCode) { isLoading = false; isError = true; this.error = error; }); notifyListeners(); } catch (e) { isLoading = false; isError = true; error = 'Something wrong happened, please contact the admin'; notifyListeners(); } } }