diff --git a/lib/Constants.dart b/lib/Constants.dart index 5b8fd9da..598fa85e 100644 --- a/lib/Constants.dart +++ b/lib/Constants.dart @@ -1,3 +1,3 @@ import 'package:flutter/material.dart'; -final Color secondaryColor = Colors.red[800]; \ No newline at end of file +final Color? secondaryColor = Colors.red[800]; \ No newline at end of file diff --git a/lib/config/config.dart b/lib/config/config.dart index d5482cb8..23c9f20a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -19,11 +19,14 @@ var PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; -// var BASE_URL = 'http://10.50.100.198:4422/'; -var BASE_URL = 'https://uat.hmgwebservices.com/'; + // var BASE_URL = 'http://10.50.100.198:2018/'; + var BASE_URL = 'https://uat.hmgwebservices.com/'; // var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; +// var BASE_URL = 'https://vidamergeuat.cloudsolutions.com.sa/'; + +// var BASE_URL = 'https://webservices.hmg.com/'; // Pharmacy UAT URLs // var BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; @@ -33,6 +36,10 @@ var BASE_URL = 'https://uat.hmgwebservices.com/'; var BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; var PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; +// Pharmacy VidaPlus URLs +// var BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapitest/api/'; +// var PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapitest/api/'; + // // Pharmacy Pre-Production URLs // var BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapitest/api/'; // var PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapitest/api/'; @@ -40,6 +47,8 @@ var PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; // RC API URL var RC_BASE_URL = 'https://rc.hmg.com/'; +// var RC_BASE_URL = 'https://ms.hmg.com/rc/'; + var PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; var GET_PROJECT = 'Services/Lists.svc/REST/GetProject'; @@ -326,7 +335,7 @@ var UPDATE_COVID_QUESTIONNAIRE = 'Services/Doctors.svc/REST/COVID19_Questionnari var CHANNEL = 3; var GENERAL_ID = 'Cs2020@2016\$2958'; var IP_ADDRESS = '10.20.10.20'; -var VERSION_ID = 10.8; +var VERSION_ID = 10.9; var SETUP_ID = '91877'; var LANGUAGE = 2; // var PATIENT_OUT_SA = 0; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 4984053d..7fd9507b 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1893,4 +1893,10 @@ const Map localizedValues = { "sickLeaveAdmittedPatient": {"en": "You cannot activate this sick leave since you're an admitted patient.", "ar": "لا يمكنك تفعيل هذه الإجازة المرضية لأنك مريض مقبل."}, "dischargeDate": {"en": "Discharge Date", "ar": "تاريخ التفريغ"}, "selectAdmissionText": {"en": "Please select one of the admissions from below to view medical reports:", "ar": "يرجى تحديد أحد حالات القبول من الأسفل لعرض التقارير الطبية:"}, + "invalidEligibility": {"en": "You cannot make online payment because you are not eligible to use the provided service.", "ar": "لا يمكنك إجراء الدفع عبر الإنترنت لأنك غير مؤهل لاستخدام الخدمة المقدمة."}, + "invalidInsurance": {"en": "You cannot make online payment because you do not have a valid insurance.", "ar": "لا يمكنك إجراء الدفع عبر الإنترنت لأنه ليس لديك تأمين صالح."}, + "continueCash": {"en": "Continue as cash", "ar": "تواصل نقدا"}, + "updateInsurance": {"en": "Update insurance", "ar": "تحديث التأمين"}, + "downloadReport": {"en": "Download Report", "ar": "تحميل تقرير المختبر"}, + "habibCallCenter": {"en": "Please contact AlHabib call center to update your insurance manually.", "ar": "يرجى الاتصال بمركز اتصال الحبيب لتحديث التأمين الخاص بك يدوياً."}, }; \ No newline at end of file diff --git a/lib/core/model/labs/patient_lab_orders.dart b/lib/core/model/labs/patient_lab_orders.dart index 3c49b80a..c2908023 100644 --- a/lib/core/model/labs/patient_lab_orders.dart +++ b/lib/core/model/labs/patient_lab_orders.dart @@ -16,6 +16,7 @@ class PatientLabOrders { int gender; String genderDescription; String invoiceNo; + String invoiceNo_VP; bool isActiveDoctorProfile; bool isDoctorAllowVedioCall; bool isExecludeDoctor; @@ -68,6 +69,7 @@ class PatientLabOrders { this.projectNameN, this.qR, this.setupID, + this.invoiceNo_VP, this.speciality,this.isLiveCareAppointment}); PatientLabOrders.fromJson(Map json) { @@ -103,6 +105,7 @@ class PatientLabOrders { projectNameN = json['ProjectNameN']; qR = json['QR']; setupID = json['SetupID']; + invoiceNo_VP = json['invoiceNo_VP']; isLiveCareAppointment = json['IsLiveCareAppointment']; // speciality = json['Speciality'].cast(); } @@ -143,6 +146,7 @@ class PatientLabOrders { data['SetupID'] = this.setupID; data['Speciality'] = this.speciality; data['IsLiveCareAppointment'] = this.isLiveCareAppointment; + data['invoiceNo_VP'] =this.invoiceNo_VP; return data; } } diff --git a/lib/core/model/labs/request_patient_lab_special_result.dart b/lib/core/model/labs/request_patient_lab_special_result.dart index bdeb3930..b3794e3c 100644 --- a/lib/core/model/labs/request_patient_lab_special_result.dart +++ b/lib/core/model/labs/request_patient_lab_special_result.dart @@ -1,5 +1,6 @@ class RequestPatientLabSpecialResult { String invoiceNo; + String invoiceNoVP; String orderNo; String setupID; String projectID; @@ -20,6 +21,7 @@ class RequestPatientLabSpecialResult { RequestPatientLabSpecialResult( {this.invoiceNo, + this.invoiceNoVP, this.orderNo, this.setupID, this.projectID, @@ -40,6 +42,7 @@ class RequestPatientLabSpecialResult { RequestPatientLabSpecialResult.fromJson(Map json) { invoiceNo = json['InvoiceNo']; + invoiceNo = json['InvoiceNo_VP']; orderNo = json['OrderNo']; setupID = json['SetupID']; projectID = json['ProjectID']; @@ -62,6 +65,7 @@ class RequestPatientLabSpecialResult { Map toJson() { final Map data = new Map(); data['InvoiceNo'] = this.invoiceNo; + data['InvoiceNo_VP'] = this.invoiceNoVP; data['OrderNo'] = this.orderNo; data['SetupID'] = this.setupID; data['ProjectID'] = this.projectID; diff --git a/lib/core/model/labs/request_send_lab_report_email.dart b/lib/core/model/labs/request_send_lab_report_email.dart index 65ac1762..2188c500 100644 --- a/lib/core/model/labs/request_send_lab_report_email.dart +++ b/lib/core/model/labs/request_send_lab_report_email.dart @@ -23,8 +23,11 @@ class RequestSendLabReportEmail { String doctorName; String projectID; String invoiceNo; + String invoiceNoVP; String orderDate; String orderNo; + bool isDownload; + int doctorID; RequestSendLabReportEmail( {this.versionID, @@ -51,8 +54,11 @@ class RequestSendLabReportEmail { this.doctorName, this.projectID, this.invoiceNo, + this.invoiceNoVP, this.orderDate, - this.orderNo}); + this.orderNo, + this.isDownload, + this.doctorID}); RequestSendLabReportEmail.fromJson(Map json) { versionID = json['VersionID']; @@ -79,8 +85,11 @@ class RequestSendLabReportEmail { doctorName = json['DoctorName']; projectID = json['ProjectID']; invoiceNo = json['InvoiceNo']; + invoiceNoVP = json['InvoiceNo_VP']; orderDate = json['OrderDate']; orderNo = json['OrderNo']; + isDownload = json['IsDownload']; + doctorID = json['DoctorID']; } Map toJson() { @@ -109,8 +118,11 @@ class RequestSendLabReportEmail { data['DoctorName'] = this.doctorName; data['ProjectID'] = this.projectID; data['InvoiceNo'] = this.invoiceNo; + data['InvoiceNo_VP'] = this.invoiceNoVP; data['OrderDate'] = this.orderDate; data['OrderNo'] = this.orderNo; + data['IsDownload'] = this.isDownload; + data['DoctorID'] = this.doctorID; return data; } } diff --git a/lib/core/model/privilege/VidaPlusProjectListModel.dart b/lib/core/model/privilege/VidaPlusProjectListModel.dart new file mode 100644 index 00000000..e56b82db --- /dev/null +++ b/lib/core/model/privilege/VidaPlusProjectListModel.dart @@ -0,0 +1,15 @@ +class VidaPlusProjectListModel { + int projectID; + + VidaPlusProjectListModel({this.projectID}); + + VidaPlusProjectListModel.fromJson(Map json) { + projectID = json['ProjectID']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + return data; + } +} diff --git a/lib/core/model/radiology/final_radiology.dart b/lib/core/model/radiology/final_radiology.dart index 7a9121fa..d92ffead 100644 --- a/lib/core/model/radiology/final_radiology.dart +++ b/lib/core/model/radiology/final_radiology.dart @@ -3,9 +3,10 @@ import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; class FinalRadiology { String setupID; int projectID; - Null patientID; + dynamic patientID; int invoiceLineItemNo; int invoiceNo; + dynamic invoiceNo_VP; int doctorID; int clinicID; DateTime orderDate; @@ -49,6 +50,7 @@ class FinalRadiology { this.patientID, this.invoiceLineItemNo, this.invoiceNo, + this.invoiceNo_VP, this.doctorID, this.clinicID, this.orderDate, @@ -92,6 +94,7 @@ class FinalRadiology { patientID = json['PatientID']; invoiceLineItemNo = json['InvoiceLineItemNo']; invoiceNo = json['InvoiceNo']; + invoiceNo_VP = json['InvoiceNo_VP']; doctorID = json['DoctorID']; clinicID = json['ClinicID']; orderDate = DateUtil.convertStringToDate(json['OrderDate']); @@ -141,6 +144,7 @@ class FinalRadiology { data['PatientID'] = this.patientID; data['InvoiceLineItemNo'] = this.invoiceLineItemNo; data['InvoiceNo'] = this.invoiceNo; + data['InvoiceNo_VP'] = this.invoiceNo_VP; data['DoctorID'] = this.doctorID; data['ClinicID'] = this.clinicID; data['OrderDate'] = this.orderDate; diff --git a/lib/core/model/radiology/request_send_rad_report_email.dart b/lib/core/model/radiology/request_send_rad_report_email.dart index a461156e..6819de0d 100644 --- a/lib/core/model/radiology/request_send_rad_report_email.dart +++ b/lib/core/model/radiology/request_send_rad_report_email.dart @@ -6,6 +6,7 @@ class RequestSendRadReportEmail { String doctorName; String generalid; int invoiceNo; + int invoiceNo_VP; String iPAdress; bool isDentalAllowedBackend; int languageID; @@ -35,6 +36,7 @@ class RequestSendRadReportEmail { this.doctorName, this.generalid, this.invoiceNo, + this.invoiceNo_VP, this.iPAdress, this.isDentalAllowedBackend, this.languageID, @@ -63,6 +65,7 @@ class RequestSendRadReportEmail { doctorName = json['DoctorName']; generalid = json['generalid']; invoiceNo = json['InvoiceNo']; + invoiceNo_VP = json['InvoiceNo_VP']; iPAdress = json['IPAdress']; isDentalAllowedBackend = json['isDentalAllowedBackend']; languageID = json['LanguageID']; @@ -94,6 +97,7 @@ class RequestSendRadReportEmail { data['DoctorName'] = this.doctorName; data['generalid'] = this.generalid; data['InvoiceNo'] = this.invoiceNo; + data['InvoiceNo_VP'] = this.invoiceNo_VP; data['IPAdress'] = this.iPAdress; data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['LanguageID'] = this.languageID; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index fb3c900a..698b3b43 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -77,6 +77,7 @@ class BaseAppClient { body['IPAdress'] = IP_ADDRESS; body['generalid'] = GENERAL_ID; + // body['isVidaPlus'] = true; body['Latitude'] = await AppSharedPreferences().getDouble(USER_LAT); body['Longitude'] = await AppSharedPreferences().getDouble(USER_LONG); @@ -149,7 +150,7 @@ class BaseAppClient { // body['IdentificationNo'] = 1023854217; // body['MobileNo'] = "531940021"; - // body['PatientID'] = 4767370; //3844083 + // body['PatientID'] = 2001273; //3844083 // body['TokenID'] = "@dm!n"; // Patient ID: 3027574 @@ -158,11 +159,11 @@ class BaseAppClient { body.removeWhere((key, value) => key == null || value == null); - // if (AppGlobal.isNetworkDebugEnabled) { + if (AppGlobal.isNetworkDebugEnabled) { print("URL : $url"); final jsonBody = json.encode(body); - print(jsonBody); - // } + print(jsonBody); + } if (await Utils.checkConnection(bypassConnectionCheck: bypassConnectionCheck)) { final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers); diff --git a/lib/core/service/medical/ask_doctor_services.dart b/lib/core/service/medical/ask_doctor_services.dart index bfb45e77..bc3c5b62 100644 --- a/lib/core/service/medical/ask_doctor_services.dart +++ b/lib/core/service/medical/ask_doctor_services.dart @@ -148,4 +148,5 @@ class AskDoctorService extends BaseService { }, body: body); return Future.value(localRes); } + } diff --git a/lib/core/service/medical/labs_service.dart b/lib/core/service/medical/labs_service.dart index 714ebcb1..15337576 100644 --- a/lib/core/service/medical/labs_service.dart +++ b/lib/core/service/medical/labs_service.dart @@ -11,6 +11,8 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da class LabsService extends BaseService { List patientLabOrdersList = List(); + String labReportPDF = ""; + Future getPatientLabOrdersList() async { hasError = false; Map body = Map(); @@ -32,11 +34,14 @@ class LabsService extends BaseService { List labResultList = List(); List labOrdersResultsList = List(); - Future getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID}) async { + Future getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID, bool isVidaPlus}) async { hasError = false; _requestPatientLabSpecialResult.projectID = projectID; _requestPatientLabSpecialResult.clinicID = clinicID; - _requestPatientLabSpecialResult.invoiceNo = invoiceNo; + + _requestPatientLabSpecialResult.invoiceNo = isVidaPlus ? "0" : invoiceNo; + _requestPatientLabSpecialResult.invoiceNoVP = isVidaPlus ? invoiceNo : "0"; + _requestPatientLabSpecialResult.orderNo = orderNo; _requestPatientLabSpecialResult.setupID = setupID; @@ -51,10 +56,11 @@ class LabsService extends BaseService { }, body: _requestPatientLabSpecialResult.toJson()); } - Future getPatientLabResult({PatientLabOrders patientLabOrder}) async { + Future getPatientLabResult({PatientLabOrders patientLabOrder, bool isVidaPlus}) async { hasError = false; Map body = Map(); - body['InvoiceNo'] = patientLabOrder.invoiceNo; + body['InvoiceNo_VP'] = isVidaPlus ? patientLabOrder.invoiceNo : "0"; + body['InvoiceNo'] = isVidaPlus ? "0" : patientLabOrder.invoiceNo; body['OrderNo'] = patientLabOrder.orderNo; body['isDentalAllowedBackend'] = false; body['SetupID'] = patientLabOrder.setupID; @@ -174,7 +180,8 @@ class LabsService extends BaseService { Future getPatientLabOrdersResults({PatientLabOrders patientLabOrder, String procedure}) async { hasError = false; Map body = Map(); - body['InvoiceNo'] = patientLabOrder.invoiceNo; + body['InvoiceNo'] = "0"; + body['InvoiceNo_VP'] = patientLabOrder.invoiceNo; body['OrderNo'] = patientLabOrder.orderNo; body['isDentalAllowedBackend'] = false; body['SetupID'] = patientLabOrder.setupID; @@ -194,9 +201,10 @@ class LabsService extends BaseService { RequestSendLabReportEmail _requestSendLabReportEmail = RequestSendLabReportEmail(); - Future sendLabReportEmail({PatientLabOrders patientLabOrder, AuthenticatedUser userObj}) async { + Future sendLabReportEmail({PatientLabOrders patientLabOrder, AuthenticatedUser userObj, bool isVidaPlus, bool isDownload = false}) async { _requestSendLabReportEmail.projectID = patientLabOrder.projectID; - _requestSendLabReportEmail.invoiceNo = patientLabOrder.invoiceNo; + _requestSendLabReportEmail.invoiceNo = isVidaPlus ? "0" : patientLabOrder.invoiceNo; + _requestSendLabReportEmail.invoiceNoVP = isVidaPlus ? patientLabOrder.invoiceNo : "0"; _requestSendLabReportEmail.doctorName = patientLabOrder.doctorName; _requestSendLabReportEmail.clinicName = patientLabOrder.clinicDescription; _requestSendLabReportEmail.patientName = userObj.firstName + " " + userObj.lastName; @@ -208,8 +216,15 @@ class LabsService extends BaseService { _requestSendLabReportEmail.projectName = patientLabOrder.projectName; _requestSendLabReportEmail.setupID = patientLabOrder.setupID; _requestSendLabReportEmail.orderNo = patientLabOrder.orderNo; + _requestSendLabReportEmail.orderNo = patientLabOrder.orderNo; + _requestSendLabReportEmail.isDownload = isDownload; + _requestSendLabReportEmail.doctorID = patientLabOrder.doctorID; - await baseAppClient.post(SEND_LAB_RESULT_EMAIL, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { + await baseAppClient.post(SEND_LAB_RESULT_EMAIL, onSuccess: (dynamic response, int statusCode) { + if (isDownload) { + labReportPDF = response['LabReportsPDFContent']; + } + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: _requestSendLabReportEmail.toJson()); diff --git a/lib/core/service/medical/radiology_service.dart b/lib/core/service/medical/radiology_service.dart index df3f0e19..f2a54c0c 100644 --- a/lib/core/service/medical/radiology_service.dart +++ b/lib/core/service/medical/radiology_service.dart @@ -1,7 +1,6 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/radiology/final_radiology.dart'; import 'package:diplomaticquarterapp/core/model/radiology/request_send_rad_report_email.dart'; -import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; @@ -9,10 +8,13 @@ class RadiologyService extends BaseService { List finalRadiologyList = List(); String url = ''; - Future getRadImageURL({int invoiceNo, int lineItem, int projectId}) async { + bool isRadiologyVIDAPlus = false; + + Future getRadImageURL({int invoiceNo, int lineItem, int projectId, bool isVidaPlus}) async { hasError = false; final Map body = new Map(); - body['InvoiceNo'] = invoiceNo; + body['InvoiceNo'] = isVidaPlus ? "0" : invoiceNo; + body['InvoiceNo_VP'] = isVidaPlus ? invoiceNo : "0"; body['LineItemNo'] = lineItem; body['ProjectID'] = projectId; @@ -28,9 +30,18 @@ class RadiologyService extends BaseService { hasError = false; await baseAppClient.post(GET_PATIENT_ORDERS, onSuccess: (dynamic response, int statusCode) { finalRadiologyList.clear(); - response['FinalRadiologyList'].forEach((radiology) { - finalRadiologyList.add(FinalRadiology.fromJson(radiology)); - }); + // response['FinalRadiologyList'].forEach((radiology) { + if (response['FinalRadiologyList'] != null && response['FinalRadiologyList'].length != 0) { + isRadiologyVIDAPlus = false; + response['FinalRadiologyList'].forEach((radiology) { + finalRadiologyList.add(FinalRadiology.fromJson(radiology)); + }); + } else { + isRadiologyVIDAPlus = true; + response['FinalRadiologyListAPI'].forEach((radiology) { + finalRadiologyList.add(FinalRadiology.fromJson(radiology)); + }); + } }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -56,6 +67,7 @@ class RadiologyService extends BaseService { _requestSendRadReportEmail.projectID = finalRadiology.projectID; _requestSendRadReportEmail.clinicName = finalRadiology.clinicDescription; _requestSendRadReportEmail.invoiceNo = finalRadiology.invoiceNo; + _requestSendRadReportEmail.invoiceNo_VP = finalRadiology.invoiceNo_VP; _requestSendRadReportEmail.invoiceLineItemNo = finalRadiology.invoiceLineItemNo; _requestSendRadReportEmail.setupID = finalRadiology.setupID; _requestSendRadReportEmail.doctorName = finalRadiology.doctorName; diff --git a/lib/core/service/medical/reports_service.dart b/lib/core/service/medical/reports_service.dart index 9f8bfb45..d80c80e4 100644 --- a/lib/core/service/medical/reports_service.dart +++ b/lib/core/service/medical/reports_service.dart @@ -29,7 +29,7 @@ class ReportsService extends BaseService { } Future getInPatientReports() async { - RequestReports _requestReportsInpatient = RequestReports(isReport: true, encounterType: 2, requestType: 2, patientOutSA: 0, projectID: 0); + RequestReports _requestReportsInpatient = RequestReports(isReport: true, encounterType: 2, requestType: 1, patientOutSA: 0, projectID: 0); hasError = false; await baseAppClient.post(REPORTS, onSuccess: (dynamic response, int statusCode) { inpatientReportsList.clear(); @@ -137,7 +137,7 @@ class ReportsService extends BaseService { body['ProjectID'] = projectID; body['Remarks'] = ""; body['ProcedureId'] = ""; - body['RequestType'] = 2; + body['RequestType'] = 1; body['Source'] = 2; body['Status'] = 1; body['CreatedBy'] = 102; diff --git a/lib/core/service/privilege_service.dart b/lib/core/service/privilege_service.dart index 5beef992..e9b2d8a9 100644 --- a/lib/core/service/privilege_service.dart +++ b/lib/core/service/privilege_service.dart @@ -1,19 +1,25 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/privilege/PrivilegeModel.dart'; +import 'package:diplomaticquarterapp/core/model/privilege/VidaPlusProjectListModel.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; class PrivilegeService extends BaseService { - List privilegeModelList = List(); + List vidaPlusProjectListModel = List(); Future getPrivilege() async { Map body = Map(); body['PatientType'] = 4; - await baseAppClient.post(GET_PRIVILEGE, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_PRIVILEGE, onSuccess: (dynamic response, int statusCode) { response['ServicePrivilegeList'].forEach((item) { privilegeModelList.add(PrivilegeModel.fromJson(item)); }); + + if (response['ProjectListVidaPlus'].length != 0) { + response['ProjectListVidaPlus'].forEach((item) { + vidaPlusProjectListModel.add(VidaPlusProjectListModel.fromJson(item)); + }); + } }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/core/viewModels/medical/labs_view_model.dart b/lib/core/viewModels/medical/labs_view_model.dart index e42dbbb4..4fbab4e6 100644 --- a/lib/core/viewModels/medical/labs_view_model.dart +++ b/lib/core/viewModels/medical/labs_view_model.dart @@ -20,6 +20,8 @@ class LabsViewModel extends BaseViewModel { List get labOrdersResultsList => _labsService.labOrdersResultsList; List timeSeries = []; + String get labReportPDF => _labsService.labReportPDF; + List _patientLabOrdersListClinic = List(); List _patientLabOrdersListHospital = List(); @@ -46,7 +48,7 @@ class LabsViewModel extends BaseViewModel { List patientLabOrdersHospital = _patientLabOrdersListHospital .where( (elementClinic) => elementClinic.filterName == element.projectName, - ) + ) .toList(); if (patientLabOrdersHospital.length != 0) { @@ -72,9 +74,14 @@ class LabsViewModel extends BaseViewModel { List labResultLists = List(); - getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID}) async { + getLaboratoryResult({String projectID, int clinicID, String invoiceNo, String orderNo, String setupID, bool isVidaPlus}) async { setState(ViewState.Busy); - await _labsService.getLaboratoryResult(invoiceNo: invoiceNo, orderNo: orderNo, projectID: projectID, clinicID: clinicID, setupID: setupID); + await _labsService.getLaboratoryResult(invoiceNo: invoiceNo, + orderNo: orderNo, + projectID: projectID, + clinicID: clinicID, + setupID: setupID, + isVidaPlus: isVidaPlus); if (_labsService.hasError) { error = _labsService.error; setState(ViewState.Error); @@ -83,9 +90,9 @@ class LabsViewModel extends BaseViewModel { } } - getPatientLabResult({PatientLabOrders patientLabOrder}) async { + getPatientLabResult({PatientLabOrders patientLabOrder, bool isVidaPlus}) async { setState(ViewState.Busy); - await _labsService.getPatientLabResult(patientLabOrder: patientLabOrder); + await _labsService.getPatientLabResult(patientLabOrder: patientLabOrder, isVidaPlus: isVidaPlus); if (_labsService.hasError) { error = _labsService.error; setState(ViewState.Error); @@ -135,11 +142,14 @@ class LabsViewModel extends BaseViewModel { } } - sendLabReportEmail({PatientLabOrders patientLabOrder, String mes, AuthenticatedUser userObj}) async { - await _labsService.sendLabReportEmail(patientLabOrder: patientLabOrder, userObj: userObj); + sendLabReportEmail({PatientLabOrders patientLabOrder, String mes, AuthenticatedUser userObj, bool isVidaPlus, bool isDownload = false}) async { + await _labsService.sendLabReportEmail(patientLabOrder: patientLabOrder, userObj: userObj, isVidaPlus: isVidaPlus, isDownload: isDownload); if (_labsService.hasError) { error = _labsService.error; - } else - AppToast.showSuccessToast(message: mes); + } else { + if (isDownload) {} else { + AppToast.showSuccessToast(message: mes); + } + } } } diff --git a/lib/core/viewModels/medical/radiology_view_model.dart b/lib/core/viewModels/medical/radiology_view_model.dart index e944b685..3ee6fedf 100644 --- a/lib/core/viewModels/medical/radiology_view_model.dart +++ b/lib/core/viewModels/medical/radiology_view_model.dart @@ -18,9 +18,14 @@ class RadiologyViewModel extends BaseViewModel { List get finalRadiologyList => filterType == FilterType.Clinic ? _finalRadiologyListClinic : _finalRadiologyListHospital; + bool _isRadiologyVIDAPlus = false; + + bool get isRadiologyVIDAPlus => _isRadiologyVIDAPlus; + void getPatientRadOrders() async { setState(ViewState.Busy); await _radiologyService.getPatientRadOrders(); + _isRadiologyVIDAPlus = _radiologyService.isRadiologyVIDAPlus; if (_radiologyService.hasError) { error = _radiologyService.error; setState(ViewState.Error); @@ -43,9 +48,9 @@ class RadiologyViewModel extends BaseViewModel { String get radImageURL => _radiologyService.url; - getRadImageURL({int invoiceNo, int lineItem, int projectId}) async { + getRadImageURL({int invoiceNo, int lineItem, int projectId, bool isVidaPlus}) async { setState(ViewState.Busy); - await _radiologyService.getRadImageURL(invoiceNo: invoiceNo, lineItem: lineItem, projectId: projectId); + await _radiologyService.getRadImageURL(invoiceNo: invoiceNo, lineItem: lineItem, projectId: projectId, isVidaPlus: isVidaPlus); if (_radiologyService.hasError) { error = _radiologyService.error; setState(ViewState.Error); diff --git a/lib/core/viewModels/project_view_model.dart b/lib/core/viewModels/project_view_model.dart index c45e7dd8..d3b7566c 100644 --- a/lib/core/viewModels/project_view_model.dart +++ b/lib/core/viewModels/project_view_model.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/privilege/PrivilegeModel.dart'; +import 'package:diplomaticquarterapp/core/model/privilege/VidaPlusProjectListModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/laser_body_parts.dart'; @@ -15,8 +16,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; var isAppArabic = false; -class ProjectViewModel extends BaseViewModel { +class ProjectViewModel extends BaseViewModel { GAnalytics get analytics => locator(); // Platform Bridge @@ -39,10 +40,14 @@ class ProjectViewModel extends BaseViewModel { double _latitude; double _longitude; - RegisterInfoResponse _registerInfo =RegisterInfoResponse(); + RegisterInfoResponse _registerInfo = RegisterInfoResponse(); + double get latitude => _latitude; + double get longitude => _longitude; - RegisterInfoResponse get registerInfo=> _registerInfo; + + RegisterInfoResponse get registerInfo => _registerInfo; + dynamic get searchValue => searchvalue; Locale get appLocal => _appLocale; @@ -54,9 +59,11 @@ class ProjectViewModel extends BaseViewModel { bool isLoginChild = false; List privilegeRootUser = List(); List privilegeChildUser = List(); + List _vidaPlusProjectListModel = List(); - List get privileges => - isLoginChild ? privilegeChildUser : privilegeChildUser; + List get privileges => isLoginChild ? privilegeChildUser : privilegeChildUser; + + List get vidaPlusProjectList => _vidaPlusProjectListModel; List selectedBodyPartList = []; @@ -64,9 +71,7 @@ class ProjectViewModel extends BaseViewModel { ProjectViewModel() { loadSharedPrefLanguage(); - subscription = Connectivity() - .onConnectivityChanged - .listen((ConnectivityResult result) { + subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { switch (result) { case ConnectivityResult.wifi: isInternetConnection = true; @@ -89,8 +94,7 @@ class ProjectViewModel extends BaseViewModel { } Future loadSharedPrefLanguage() async { - currentLanguage = - await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + currentLanguage = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); _appLocale = Locale(currentLanguage); isAppArabic = _isArabic = currentLanguage == 'ar'; notifyListeners(); @@ -121,6 +125,11 @@ class ProjectViewModel extends BaseViewModel { notifyListeners(); } + setVidaPlusProjectList(List vidaPlusProjectListModelInput) { + _vidaPlusProjectListModel = vidaPlusProjectListModelInput; + notifyListeners(); + } + setPrivilege({privilegeList, bool isLoginChild = false}) { List privilege = List(); @@ -166,8 +175,9 @@ class ProjectViewModel extends BaseViewModel { searchvalue = data; notifyListeners(); } - setRegisterData(RegisterInfoResponse data){ - _registerInfo =data; + + setRegisterData(RegisterInfoResponse data) { + _registerInfo = data; notifyListeners(); } } diff --git a/lib/d_q_icons_icons.dart b/lib/d_q_icons_icons.dart index 7376b1ca..19c04948 100644 --- a/lib/d_q_icons_icons.dart +++ b/lib/d_q_icons_icons.dart @@ -19,7 +19,7 @@ class DQIcons { DQIcons._(); static const _kFontFam = 'DQIcons'; - static const String _kFontPkg = null; + static const Null _kFontPkg = null; static const IconData blood_pressure = IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg); diff --git a/lib/main.dart b/lib/main.dart index f2faf588..36e86ed9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -36,16 +36,16 @@ class MyApp extends StatefulWidget { @override _MyApp createState() => new _MyApp(); } - -class MyHttpOverrides extends HttpOverrides { +class MyHttpOverrides extends HttpOverrides{ @override - HttpClient createHttpClient(SecurityContext context) { - return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true; + HttpClient createHttpClient(SecurityContext? context){ + return super.createHttpClient(context) + ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true; } } class _MyApp extends State { - AppUpdateInfo _updateInfo; + late AppUpdateInfo _updateInfo; final GlobalKey navigatorKey = GlobalKey(); @@ -70,7 +70,7 @@ class _MyApp extends State { // var font = projectProvider.isArabic ? 'Cairo' : 'WorkSans'; // Re-enable once going live - if (Platform.isAndroid) checkForUpdate(); + // if (Platform.isAndroid) checkForUpdate(); ThemeNotifier(defaultTheme()); super.initState(); @@ -121,10 +121,10 @@ class _MyApp extends State { ], child: Consumer( builder: (context, projectProvider, child) => MaterialApp( - builder: (BuildContext context, Widget child) { + builder: (_, __) { return MediaQuery( - data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0,), //set desired text scale factor here - child: child, + data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0,), //set desired text scale factor here + child: child ?? SizedBox(), ); }, navigatorKey: locator().navigatorKey, diff --git a/lib/models/anicllary-orders/ancillary_order_list_model.dart b/lib/models/anicllary-orders/ancillary_order_list_model.dart index 76ef3a7d..56cfeb31 100644 --- a/lib/models/anicllary-orders/ancillary_order_list_model.dart +++ b/lib/models/anicllary-orders/ancillary_order_list_model.dart @@ -1,6 +1,6 @@ class AncillaryOrdersListModel { List ancillaryOrderList; - Null errCode; + dynamic errCode; String message; int patientID; String patientName; @@ -32,7 +32,7 @@ class AncillaryOrdersListModel { errCode = json['ErrCode']; message = json['Message']; patientID = json['PatientID']; - patientName = json['PatientName']; + patientName = json['PatientName'] != null ? json['PatientName'] : ""; patientType = json['PatientType']; projectID = json['ProjectID']; projectName = json['ProjectName']; @@ -83,7 +83,7 @@ class AncillaryOrderList { appointmentDate = json['AppointmentDate']; appointmentNo = json['AppointmentNo']; clinicID = json['ClinicID']; - clinicName = json['ClinicName']; + clinicName = json['ClinicName'] != null ? json['ClinicName'] : ""; doctorID = json['DoctorID']; doctorName = json['DoctorName']; orderDate = json['OrderDate']; diff --git a/lib/models/anicllary-orders/ancillary_orders_proc_list.dart b/lib/models/anicllary-orders/ancillary_orders_proc_list.dart new file mode 100644 index 00000000..ed22bd05 --- /dev/null +++ b/lib/models/anicllary-orders/ancillary_orders_proc_list.dart @@ -0,0 +1,18 @@ +class AncillaryOrdersProcedureList { + int procedureID; + String procedureDescription; + + AncillaryOrdersProcedureList({this.procedureID, this.procedureDescription}); + + AncillaryOrdersProcedureList.fromJson(Map json) { + procedureID = json['ProcedureID']; + procedureDescription = json['ProcedureDescription']; + } + + Map toJson() { + final Map data = new Map(); + data['ProcedureID'] = this.procedureID; + data['ProcedureDescription'] = this.procedureDescription; + return data; + } +} diff --git a/lib/models/tamara_request_model.dart b/lib/models/tamara_request_model.dart index bbfd8622..d75fe4b0 100644 --- a/lib/models/tamara_request_model.dart +++ b/lib/models/tamara_request_model.dart @@ -10,7 +10,7 @@ class TamaraRequestModel { String customerEmail; String orderDescription; bool isInstallment; - int projectID; + num projectID; String accessCode; String sHARequestPhase; String sHAResponsePhase; diff --git a/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart b/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart index da5ce04a..b1b457f5 100644 --- a/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart +++ b/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/anicllary-orders/ancillary_order_proc_model.dart'; +import 'package:diplomaticquarterapp/models/anicllary-orders/ancillary_orders_proc_list.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; @@ -571,7 +572,6 @@ class _AnicllaryOrdersState extends State with SingleTic } else { checkPaymentStatus(appo); } - } checkTamaraPaymentStatus(String orderID, AppoitmentAllHistoryResultList appo) { @@ -633,18 +633,21 @@ class _AnicllaryOrdersState extends State with SingleTic createAdvancePayment(res, AppoitmentAllHistoryResultList appo) { DoctorsListService service = new DoctorsListService(); String paymentReference = res['Fort_id'].toString(); - service.HIS_createAdvancePayment( - appo, - widget.projectID.toString(), - res['Amount'], - res['Fort_id'], - res['PaymentMethod'], - projectViewModel.user.patientType, - projectViewModel.user.firstName + " " + projectViewModel.user.lastName, - projectViewModel.user.patientID, - localContext) + // List ancillaryOrdersProcedureList = []; + // selectedProcList.forEach((element) { + // ancillaryOrdersProcedureList.add(new AncillaryOrdersProcedureList(procedureID: num.parse(element.procedureID), procedureDescription: element.procedureName)); + // }); + service.HIS_createAdvancePayment(appo, widget.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], projectViewModel.user.patientType, + projectViewModel.user.firstName + " " + projectViewModel.user.lastName, projectViewModel.user.patientID, localContext, + isAncillaryOrder: true) .then((res) { - addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, 0, appo); + addAdvancedNumberRequest( + Utils.isVidaPlusProject(projectViewModel, widget.projectID) + ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() + : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), + paymentReference, + 0, + appo); }).catchError((err) { GifLoaderDialogUtils.hideDialog(localContext); AppToast.showErrorToast(message: err); @@ -665,7 +668,6 @@ class _AnicllaryOrdersState extends State with SingleTic autoGenerateInvoice() { List selectedProcListAPI = []; - Map selectedProcListAPIMap; selectedProcList.forEach((element) { selectedProcListAPI.add({ diff --git a/lib/pages/Blood/confirm_payment_page.dart b/lib/pages/Blood/confirm_payment_page.dart index 149d1a33..700d5471 100644 --- a/lib/pages/Blood/confirm_payment_page.dart +++ b/lib/pages/Blood/confirm_payment_page.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/my_balance/AdvanceModel.dart'; import 'package:diplomaticquarterapp/core/model/my_balance/patient_info_and_mobile_number.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; @@ -20,6 +21,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; import 'dialogs/ConfirmSMSDialog.dart'; import 'new_text_Field.dart'; @@ -31,11 +33,13 @@ class ConfirmPaymentPage extends StatelessWidget { MyInAppBrowser browser; AuthenticatedUser authenticatedUser; AppSharedPreferences sharedPref = AppSharedPreferences(); + ProjectViewModel projectViewModel; ConfirmPaymentPage({this.advanceModel, this.patientInfoAndMobileNumber, this.selectedPaymentMethod, this.authenticatedUser}); @override Widget build(BuildContext context) { + projectViewModel = Provider.of(context); void showSMSDialog() { showDialog( context: context, @@ -250,8 +254,13 @@ class ConfirmPaymentPage extends StatelessWidget { GifLoaderDialogUtils.showMyDialog(AppGlobal.context); service.createAdvancePayment(appo, appo.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], AppGlobal.context).then((res) { GifLoaderDialogUtils.hideDialog(AppGlobal.context); - print(res['OnlineCheckInAppointments'][0]['AdvanceNumber']); - addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, appo.appointmentNo.toString(), appo); + addAdvancedNumberRequest( + Utils.isVidaPlusProject(projectViewModel, appo.projectID) + ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() + : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), + paymentReference, + appo.appointmentNo.toString(), + appo); }).catchError((err) { GifLoaderDialogUtils.hideDialog(AppGlobal.context); AppToast.showErrorToast(message: err); diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 0405f657..50dbc70f 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -59,6 +59,10 @@ class _BookConfirmState extends State { AppSharedPreferences sharedPref = new AppSharedPreferences(); + bool isInsured = false; + bool isEligible = false; + bool isCash = false; + @override void initState() { // widget.authUser = new AuthenticatedUser(); @@ -331,9 +335,9 @@ class _BookConfirmState extends State { AppToast.showSuccessToast(message: TranslationBase.of(context).bookedSuccess); Future.delayed(new Duration(milliseconds: 500), () { - checkPatientNphiesEligibility(docObject, res['AppointmentNo'], context); - // getPatientShare(context, res['AppointmentNo'], docObject.clinicID, docObject.projectID, docObject); - // getToDoCount(); + // checkPatientNphiesEligibility(docObject, res['AppointmentNo'], context); + getToDoCount(); + getPatientShare(context, res['AppointmentNo'], docObject.clinicID, docObject.projectID, docObject); }); widget.service.logDoctorFreeSlots(docObject.doctorID, docObject.clinicID, docObject.projectID, decodedLogs, res['AppointmentNo'], context).then((res) { @@ -437,13 +441,40 @@ class _BookConfirmState extends State { } getPatientShare(context, String appointmentNo, int clinicID, int projectID, DoctorList docObject) { + String errorMsg = ""; GifLoaderDialogUtils.showMyDialog(context); widget.service.getPatientShare(appointmentNo, clinicID, projectID, context).then((res) { projectViewModel.selectedBodyPartList.clear(); projectViewModel.laserSelectionDuration = 0; print(res); - widget.patientShareResponse = new PatientShareResponse.fromJson(res); - navigateToBookSuccess(context, docObject, widget.patientShareResponse); + widget.patientShareResponse = new PatientShareResponse.fromJson(res['OnlineCheckInAppointments'][0]); + + isInsured = res["IsInsured"]; + isEligible = res["IsEligible"]; + isCash = res["IsCash"]; + + if (isCash) { + navigateToBookSuccess(context, docObject, widget.patientShareResponse); + } else { + if (isInsured && isEligible) { + navigateToBookSuccess(context, docObject, widget.patientShareResponse); + } else { + if (isInsured && !isEligible) { + errorMsg = TranslationBase.of(context).invalidEligibility; + } else { + errorMsg = TranslationBase.of(context).invalidInsurance; + } + ConfirmDialog dialog = new ConfirmDialog( + isDissmissable: false, + context: context, + confirmMessage: errorMsg, + okText: TranslationBase.of(context).updateInsuranceText, + cancelText: TranslationBase.of(context).continueCash, + okFunction: () => {openUpdateInsurance()}, + cancelFunction: () => {continueAsCash(docObject, appointmentNo)}); + dialog.showAlertDialog(context); + } + } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); // AppToast.showErrorToast(message: err); diff --git a/lib/pages/BookAppointment/BookSuccess.dart b/lib/pages/BookAppointment/BookSuccess.dart index 890b96d8..83c3fdbd 100644 --- a/lib/pages/BookAppointment/BookSuccess.dart +++ b/lib/pages/BookAppointment/BookSuccess.dart @@ -1,6 +1,5 @@ import 'dart:io'; -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; @@ -46,6 +45,7 @@ class BookSuccess extends StatefulWidget { class _BookSuccessState extends State { AppSharedPreferences sharedPref = AppSharedPreferences(); + // AuthenticatedUser authUser; ProjectViewModel projectViewModel; @@ -775,7 +775,13 @@ class _BookSuccessState extends State { DoctorsListService service = new DoctorsListService(); String paymentReference = res['Fort_id'].toString(); service.createAdvancePayment(appo, appo.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], context).then((res) { - addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, appo.appointmentNo.toString(), appo); + addAdvancedNumberRequest( + Utils.isVidaPlusProject(projectViewModel, appo.projectID) + ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() + : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), + paymentReference, + appo.appointmentNo.toString(), + appo); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index dc126e78..26deb0f8 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -609,6 +609,8 @@ class _SearchByClinicState extends State { result = LinkedHashSet.from(arr).toList(); numAll = result.length; + nearestAppo = false; + isProjectLoaded = false; navigateToSearchResults(context, doctorsList, _patientDoctorAppointmentListHospital); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); diff --git a/lib/pages/Covid-DriveThru/covid-drivethru-location.dart b/lib/pages/Covid-DriveThru/covid-drivethru-location.dart index 4d0479e6..c85f53ae 100644 --- a/lib/pages/Covid-DriveThru/covid-drivethru-location.dart +++ b/lib/pages/Covid-DriveThru/covid-drivethru-location.dart @@ -126,7 +126,7 @@ class _CovidDrivethruLocationState extends State { value: item, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [Text(item.projectName), getCovidTestTypeImage(item)], + children: [Text(item.projectName ?? ""), getCovidTestTypeImage(item)], ), ); }).toList(), diff --git a/lib/pages/Covid-DriveThru/covid-payment-summary.dart b/lib/pages/Covid-DriveThru/covid-payment-summary.dart index d23be14a..e1f00173 100644 --- a/lib/pages/Covid-DriveThru/covid-payment-summary.dart +++ b/lib/pages/Covid-DriveThru/covid-payment-summary.dart @@ -402,8 +402,12 @@ class _CovidPaymentSummaryState extends State { DoctorsListService service = new DoctorsListService(); String paymentReference = res['Fort_id'].toString(); service.createAdvancePayment(appo, appo.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], context).then((res) { - print(res['OnlineCheckInAppointments'][0]['AdvanceNumber']); - addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, appo.appointmentNo.toString()); + addAdvancedNumberRequest( + Utils.isVidaPlusProject(projectViewModel, appo.projectID) + ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() + : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), + paymentReference, + appo.appointmentNo.toString()); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index d3705a7c..75290ab1 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -79,6 +79,10 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { bool dataLoaded = false; + bool isInsured = false; + bool isEligible = false; + bool isCash = false; + @override void initState() { widget.patientShareResponse = new PatientShareResponse(); @@ -543,8 +547,8 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { confirmAppointment(appo); break; case 20: - // getPatientShare(context, appo); - checkPatientNphiesEligibility(context, appo); + getPatientShare(context, appo); + // checkPatientNphiesEligibility(context, appo); break; case 30: getAppoQR(context, appo); @@ -889,6 +893,7 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { } getPatientShare(context, AppoitmentAllHistoryResultList appo) { + String errorMsg = ""; DoctorsListService service = new DoctorsListService(); if (appo.isLiveCareAppointment) { getLiveCareAppointmentPatientShare(context, service, appo); @@ -896,8 +901,33 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { GifLoaderDialogUtils.showMyDialog(context); service.getPatientShare(appo.appointmentNo.toString(), appo.clinicID, appo.projectID, context).then((res) { GifLoaderDialogUtils.hideDialog(context); - widget.patientShareResponse = new PatientShareResponse.fromJson(res); - openPaymentDialog(appo, widget.patientShareResponse); + widget.patientShareResponse = new PatientShareResponse.fromJson(res['OnlineCheckInAppointments'][0]); + isInsured = res["IsInsured"]; + isEligible = res["IsEligible"]; + isCash = res["IsCash"]; + + if (isCash) { + openPaymentDialog(appo, widget.patientShareResponse); + } else { + if (isInsured && isEligible) { + openPaymentDialog(appo, widget.patientShareResponse); + } else { + if (isInsured && !isEligible) { + errorMsg = TranslationBase.of(context).invalidEligibility; + } else { + errorMsg = TranslationBase.of(context).invalidInsurance; + } + ConfirmDialog dialog = new ConfirmDialog( + isDissmissable: false, + context: context, + confirmMessage: errorMsg, + okText: TranslationBase.of(context).updateInsuranceText, + cancelText: TranslationBase.of(context).continueCash, + okFunction: () => {openUpdateInsurance()}, + cancelFunction: () => {continueAsCash(appo)}); + dialog.showAlertDialog(context); + } + } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); @@ -1181,7 +1211,14 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { String paymentReference = res['Fort_id'].toString(); service.createAdvancePayment(appo, appo.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], context).then((res) { GifLoaderDialogUtils.hideDialog(context); - addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, appo.appointmentNo.toString(), appo, res['OnlineCheckInAppointments'][0]); + addAdvancedNumberRequest( + Utils.isVidaPlusProject(projectViewModel, appo.projectID) + ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() + : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), + paymentReference, + appo.appointmentNo.toString(), + appo, + res['OnlineCheckInAppointments'][0]); }).catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); diff --git a/lib/pages/feedback/send_feedback_page.dart b/lib/pages/feedback/send_feedback_page.dart index 2badddd5..06e9560b 100644 --- a/lib/pages/feedback/send_feedback_page.dart +++ b/lib/pages/feedback/send_feedback_page.dart @@ -218,17 +218,17 @@ class _SendFeedbackPageState extends State { inputWidget(TranslationBase.of(context).subject, "", titleController), SizedBox(height: 12), inputWidget(TranslationBase.of(context).message, "", messageController, lines: 11, suffixTap: () async { - // if (Platform.isAndroid) { - // if (await PermissionService.isMicrophonePermissionEnabled()) { - // openSpeechReco(); - // } else { - // Utils.showPermissionConsentDialog(context, TranslationBase.of(context).recordAudioPermission, () { - // openSpeechReco(); - // }); - // } - // } else { - // openSpeechReco(); - // } + if (Platform.isAndroid) { + if (await PermissionService.isMicrophonePermissionEnabled()) { + openSpeechReco(); + } else { + Utils.showPermissionConsentDialog(context, TranslationBase.of(context).recordAudioPermission, () { + openSpeechReco(); + }); + } + } else { + openSpeechReco(); + } }), SizedBox(height: 12), InkWell( @@ -340,7 +340,7 @@ class _SendFeedbackPageState extends State { }); } }, - color: (titleController.text.toString().isEmpty || messageController.text.toString().isEmpty) ? Color(0xffEAEAEA) : Color(0xffD02127), + color: Color(0xffD02127), textColor: Colors.white, disabledColor: Color(0xffEAEAEA), ), @@ -405,8 +405,8 @@ class _SendFeedbackPageState extends State { color: Color(0xff575757), letterSpacing: -0.56, ), - // suffixIconConstraints: BoxConstraints(minWidth: 50), - // suffixIcon: suffixTap == null ? null : IconButton(icon: Icon(Icons.mic, color: Color(0xff2E303A)), onPressed: suffixTap), + suffixIconConstraints: BoxConstraints(minWidth: 50), + suffixIcon: suffixTap == null ? null : IconButton(icon: Icon(Icons.mic, color: Color(0xff2E303A)), onPressed: suffixTap), contentPadding: EdgeInsets.zero, border: InputBorder.none, focusedBorder: InputBorder.none, @@ -517,25 +517,25 @@ class _SendFeedbackPageState extends State { return; } - // openSpeechReco() async { - // new RoboSearch(context: context).showAlertDialog(context); - // _currentLocaleId = TranslationBase.of(AppGlobal.context).locale.languageCode; - // bool available = await speech.initialize(onStatus: statusListener, onError: errorListener); - // if (available) { - // speech.listen( - // onResult: resultListener, - // listenMode: stt.ListenMode.confirmation, - // localeId: _currentLocaleId == 'en' ? 'en-US' : 'ar-SA', - // ); - // } else { - // print("The user has denied the use of speech recognition."); - // } - // } - // + openSpeechReco() async { + new RoboSearch(context: context).showAlertDialog(context); + _currentLocaleId = TranslationBase.of(AppGlobal.context).locale.languageCode; + // bool available = await speech.initialize(onStatus: statusListener, onError: errorListener); + // if (available) { + // speech.listen( + // onResult: resultListener, + // listenMode: stt.ListenMode.confirmation, + // localeId: _currentLocaleId == 'en' ? 'en-US' : 'ar-SA', + // ); + // } else { + // print("The user has denied the use of speech recognition."); + // } + } + // void errorListener(SpeechRecognitionError error) { // event.setValue({"searchText": 'null'}); - // //SpeechToText.closeAlertDialog(context); - // print(error); + // SpeechToText.closeAlertDialog(context); + // print(error); // } void statusListener(String status) { @@ -561,9 +561,9 @@ class _SendFeedbackPageState extends State { } } - // Future initSpeechState() async { - // bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); - // print(hasSpeech); - // if (!mounted) return; - // } + Future initSpeechState() async { + // bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); + // print(hasSpeech); + // if (!mounted) return; + } } diff --git a/lib/pages/insurance/AttachInsuranceCardImageDialog.dart b/lib/pages/insurance/AttachInsuranceCardImageDialog.dart index c331da2a..03e61116 100644 --- a/lib/pages/insurance/AttachInsuranceCardImageDialog.dart +++ b/lib/pages/insurance/AttachInsuranceCardImageDialog.dart @@ -132,7 +132,15 @@ class _AttachInsuranceCardImageDialogState extends State { Navigator.pop(context), Navigator.push( - context, - FadePage( - page: UpdateInsuranceManually( + context, + FadePage( + page: UpdateInsuranceManually( patientIdentificationNo: patientIdentificationID, patientID: patientID, patientMobileNumber: mobileNumber, - ))) + ), + ), + ), }, cancelFunction: () => {}); dialog.showAlertDialog(context); diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 94747b37..adcc4820 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -256,7 +256,7 @@ class _Login extends State { sharedPref.setObject(REGISTER_DATA_FOR_REGISTER, request); GifLoaderDialogUtils.showMyDialog(context); authService.checkPatientAuthentication(request).then((value) { - if (value['UserAccountIsActivated']) { + // if (value['UserAccountIsActivated']) { if (value['isSMSSent']) { sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']); sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request); @@ -267,17 +267,17 @@ class _Login extends State { this.checkActivationCode(); } } - } else { - ConfirmDialog activationDialog = new ConfirmDialog( - context: context, - confirmMessage: TranslationBase.of(context).accountDeactivatedMsg, - okText: TranslationBase.of(context).yes, - cancelText: TranslationBase.of(context).no, - okFunction: () => {ConfirmDialog.closeAlertDialog(context), this.activatePatientFile()}, - cancelFunction: () => {}); - GifLoaderDialogUtils.hideDialog(context); - activationDialog.showAlertDialog(context); - } + // } else { + // ConfirmDialog activationDialog = new ConfirmDialog( + // context: context, + // confirmMessage: TranslationBase.of(context).accountDeactivatedMsg, + // okText: TranslationBase.of(context).yes, + // cancelText: TranslationBase.of(context).no, + // okFunction: () => {ConfirmDialog.closeAlertDialog(context), this.activatePatientFile()}, + // cancelFunction: () => {}); + // GifLoaderDialogUtils.hideDialog(context); + // activationDialog.showAlertDialog(context); + // } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); ConfirmDialog dialog = new ConfirmDialog( diff --git a/lib/pages/medical/ask_doctor/ask_doctor_page.dart b/lib/pages/medical/ask_doctor/ask_doctor_page.dart index 19636d62..463f7fb9 100644 --- a/lib/pages/medical/ask_doctor/ask_doctor_page.dart +++ b/lib/pages/medical/ask_doctor/ask_doctor_page.dart @@ -60,6 +60,7 @@ class AskDoctorPage extends StatelessWidget { itemBuilder: (context, _index) { DoctorList _doctor = _doctorList[_index]; DoctorList doctorList = DoctorList( + date: _doctor.date, projectID: _doctor.projectID, setupID: _doctor.setupID, clinicID: _doctor.clinicID, diff --git a/lib/pages/medical/ask_doctor/doctor_response.dart b/lib/pages/medical/ask_doctor/doctor_response.dart index 0dd9b9a1..1ff9def7 100644 --- a/lib/pages/medical/ask_doctor/doctor_response.dart +++ b/lib/pages/medical/ask_doctor/doctor_response.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/viewModels/medical/ask_doctor_view_mod import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -27,7 +28,7 @@ class DoctorResponse extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( - height: 65, + height: 16, ), AppExpandableNotifier( headerWidget: Padding( @@ -61,14 +62,18 @@ class DoctorResponse extends StatelessWidget { return InkWell( onTap: () { ///go to page ViewDoctorResponsesPage - Navigator.push( - context, - FadePage( - page: ViewDoctorResponsesPage( - doctorResponse: doctor, + if (doctor.transactions != null && doctor.transactions.isNotEmpty) { + Navigator.push( + context, + FadePage( + page: ViewDoctorResponsesPage( + doctorResponse: doctor, + ), ), - ), - ); + ); + } else { + Utils.showErrorToast("There are no doctor responses for this request."); + } }, child: Container( height: 100, diff --git a/lib/pages/medical/balance/confirm_payment_page.dart b/lib/pages/medical/balance/confirm_payment_page.dart index b3b29384..0697ea75 100644 --- a/lib/pages/medical/balance/confirm_payment_page.dart +++ b/lib/pages/medical/balance/confirm_payment_page.dart @@ -468,7 +468,13 @@ class _ConfirmPaymentPageState extends State { service.HIS_createAdvancePayment(appo, widget.advanceModel.hospitalsModel.iD.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], widget.patientInfoAndMobileNumber.patientType, widget.advanceModel.patientName, widget.advanceModel.fileNumber, AppGlobal.context) .then((res) { - addAdvancedNumberRequest(res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, 0, appo); + addAdvancedNumberRequest( + Utils.isVidaPlusProject(projectViewModel, widget.advanceModel.hospitalsModel.iD) + ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() + : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), + paymentReference, + 0, + appo); }).catchError((err) { GifLoaderDialogUtils.hideDialog(AppGlobal.context); AppToast.showErrorToast(message: err); diff --git a/lib/pages/medical/balance/my_balance_page.dart b/lib/pages/medical/balance/my_balance_page.dart index a7a6d5d7..6783c895 100644 --- a/lib/pages/medical/balance/my_balance_page.dart +++ b/lib/pages/medical/balance/my_balance_page.dart @@ -106,7 +106,7 @@ class MyBalancePage extends StatelessWidget { ), ), Text( - TranslationBase.of(context).sar, + projectViewModel.user.outSA == 1 ? TranslationBase.of(context).aed : TranslationBase.of(context).sar, style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, @@ -157,7 +157,7 @@ class MyBalancePage extends StatelessWidget { ), ), Text( - amount.toStringAsFixed(2) + " " + TranslationBase.of(context).sar, + amount.toStringAsFixed(2) + " " + (projectViewModel.user.outSA == 1 ? TranslationBase.of(context).aed : TranslationBase.of(context).sar), style: TextStyle( fontSize: 16, letterSpacing: -0.64, diff --git a/lib/pages/medical/labs/laboratory_result_page.dart b/lib/pages/medical/labs/laboratory_result_page.dart index 847f979b..d5bb9035 100644 --- a/lib/pages/medical/labs/laboratory_result_page.dart +++ b/lib/pages/medical/labs/laboratory_result_page.dart @@ -1,13 +1,22 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:typed_data'; + import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/LabResult/laboratory_result_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:open_filex/open_filex.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; class LaboratoryResultPage extends StatefulWidget { @@ -25,11 +34,13 @@ class _LaboratoryResultPageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getLaboratoryResult( - invoiceNo: widget.patientLabOrders.invoiceNo, - clinicID: widget.patientLabOrders.clinicID, - projectID: widget.patientLabOrders.projectID, - orderNo: widget.patientLabOrders.orderNo, - setupID: widget.patientLabOrders.setupID), + invoiceNo: widget.patientLabOrders.invoiceNo, + clinicID: widget.patientLabOrders.clinicID, + projectID: widget.patientLabOrders.projectID, + orderNo: widget.patientLabOrders.orderNo, + setupID: widget.patientLabOrders.setupID, + isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrders.projectID)), + ), builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarTitle: widget.patientLabOrders.doctorName, @@ -37,27 +48,73 @@ class _LaboratoryResultPageState extends State { showNewAppBar: true, showNewAppBarTitle: true, backgroundColor: Color(0xffF8F8F8), - body: ListView.builder( - physics: BouncingScrollPhysics(), - padding: EdgeInsets.only(bottom: 12), - itemBuilder: (context, index) => LaboratoryResultWidget( - onTap: () async { - GifLoaderDialogUtils.showMyDialog(context); - await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc, userObj: projectViewModel.user); - GifLoaderDialogUtils.hideDialog(context); - }, - billNo: widget.patientLabOrders.invoiceNo, - // details: model.patientLabSpecialResult[index].resultDataHTML, - details: model.patientLabSpecialResult.isEmpty ? null : getSpecialResults(model), - orderNo: widget.patientLabOrders.orderNo, - patientLabOrder: widget.patientLabOrders, + body: SingleChildScrollView( + child: Column( + children: [ + ListView.builder( + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.only(bottom: 12), + itemBuilder: (context, index) => LaboratoryResultWidget( + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc, userObj: projectViewModel.user, isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrders.projectID))); + GifLoaderDialogUtils.hideDialog(context); + }, + billNo: widget.patientLabOrders.invoiceNo, + // details: model.patientLabSpecialResult[index].resultDataHTML, + details: model.patientLabSpecialResult.isEmpty ? null : getSpecialResults(model), + orderNo: widget.patientLabOrders.orderNo, + patientLabOrder: widget.patientLabOrders, + ), + itemCount: 1, + ), + SizedBox( + height: 120.0, + ) + ], ), - itemCount: 1, ), + // bottomSheet: Container( + // color: Colors.white, + // height: MediaQuery.of(context).size.height * 0.081, + // width: double.infinity, + // padding: EdgeInsets.all(12.0), + // child: Column( + // children: [ + // Container( + // width: MediaQuery.of(context).size.width * 0.9, + // child: DefaultButton( + // TranslationBase.of(context).downloadReport, + // () async { + // GifLoaderDialogUtils.showMyDialog(context); + // await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc, userObj: projectViewModel.user, isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrders.projectID)), isDownload: true); + // GifLoaderDialogUtils.hideDialog(context); + // try { + // String path = await _createFileFromString(model.labReportPDF, "pdf"); + // OpenFilex.open(path); + // } catch (ex) { + // AppToast.showErrorToast(message: "Cannot open file."); + // } + // }, + // textColor: Colors.white, + // ), + // ), + // ], + // ), + // ), ), ); } + Future _createFileFromString(String encodedStr, String ext) async { + Uint8List bytes = base64.decode(encodedStr); + String dir = (await getApplicationDocumentsDirectory()).path; + File file = File("$dir/" + DateTime.now().millisecondsSinceEpoch.toString() + "." + ext); + await file.writeAsBytes(bytes); + return file.path; + } + String getSpecialResults(LabsViewModel model) { String labResults = ""; model.patientLabSpecialResult.forEach((element) { diff --git a/lib/pages/medical/radiology/radiology_details_page.dart b/lib/pages/medical/radiology/radiology_details_page.dart index a84acbae..7e609370 100644 --- a/lib/pages/medical/radiology/radiology_details_page.dart +++ b/lib/pages/medical/radiology/radiology_details_page.dart @@ -1,12 +1,12 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/radiology/final_radiology.dart'; -import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/radiology_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/header_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_send_email_dialog.dart'; @@ -19,14 +19,19 @@ import 'package:url_launcher/url_launcher.dart'; class RadiologyDetailsPage extends StatelessWidget { final FinalRadiology finalRadiology; + bool isRadiologyVidaPlus; - RadiologyDetailsPage({Key key, this.finalRadiology}); + RadiologyDetailsPage({Key key, this.finalRadiology, this.isRadiologyVidaPlus}); @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getRadImageURL(projectId: finalRadiology.projectID, lineItem: finalRadiology.invoiceLineItemNo, invoiceNo: finalRadiology.invoiceNo), + onModelReady: (model) => model.getRadImageURL( + projectId: finalRadiology.projectID, + lineItem: finalRadiology.invoiceLineItemNo, + invoiceNo: Utils.isVidaPlusProject(projectViewModel, finalRadiology.projectID) ? finalRadiology.invoiceNo_VP : finalRadiology.invoiceNo, + isVidaPlus: Utils.isVidaPlusProject(projectViewModel, finalRadiology.projectID)), builder: (_, model, widget) => AppScaffold( appBarTitle: TranslationBase.of(context).report, isShowAppBar: true, @@ -45,7 +50,7 @@ class RadiologyDetailsPage extends StatelessWidget { finalRadiology.doctorID, finalRadiology.doctorImageURL, finalRadiology.speciality, - finalRadiology.invoiceNo.toString(), + Utils.isVidaPlusProject(projectViewModel, finalRadiology.projectID) ? finalRadiology.invoiceNo_VP.toString() : finalRadiology.invoiceNo.toString(), finalRadiology.projectName, finalRadiology.orderDate, null, diff --git a/lib/pages/medical/radiology/radiology_home_page.dart b/lib/pages/medical/radiology/radiology_home_page.dart index 4e22dcf6..9fc49cb5 100644 --- a/lib/pages/medical/radiology/radiology_home_page.dart +++ b/lib/pages/medical/radiology/radiology_home_page.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/medical/radiology/radiology_details_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; import 'package:diplomaticquarterapp/widgets/new_design/my_tab_view.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; @@ -78,12 +79,14 @@ class RadiologyHomePage extends StatelessWidget { FadePage( page: RadiologyDetailsPage( finalRadiology: radiology, + isRadiologyVidaPlus: Utils.isVidaPlusProject(projectViewModel, radiology.projectID), ), ), ), isInOutPatient: radiology.isInOutPatient, name: TranslationBase.of(context).dr + " " + radiology.doctorName, - billNo: radiology.invoiceNo.toString(), + billNo: Utils.isVidaPlusProject(projectViewModel, radiology.projectID) ? radiology.invoiceNo_VP.toString() : radiology.invoiceNo.toString(), + // billNo: radiology.invoiceNo_VP.toString(), profileUrl: radiology.doctorImageURL, subName: _isSortByClinic ? radiology.projectName : radiology.clinicDescription, isLiveCareAppointment: radiology.isLiveCareAppointment, diff --git a/lib/pages/medical/reports/report_home_page.dart b/lib/pages/medical/reports/report_home_page.dart index 7cc8fc2b..55d1b901 100644 --- a/lib/pages/medical/reports/report_home_page.dart +++ b/lib/pages/medical/reports/report_home_page.dart @@ -70,74 +70,73 @@ class _HomeReportPageState extends State with SingleTickerProvid body: Container( child: Column( children: [ - TabBar( - controller: _tabController_new, - indicatorWeight: 3.0, - indicatorSize: TabBarIndicatorSize.tab, - labelColor: Color(0xff2B353E), - unselectedLabelColor: Color(0xff575757), - labelPadding: EdgeInsets.only(top: 15, bottom: 13, left: 20, right: 20), - labelStyle: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - letterSpacing: -0.48, - ), - unselectedLabelStyle: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - letterSpacing: -0.48, - ), - onTap: (int value) { - print(value); - setState(() {}); - }, - tabs: [ - Text( - TranslationBase.of(context).outpatient, - style: TextStyle(fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins'), - ), - Text( - TranslationBase.of(context).inPatient, - style: TextStyle(fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins'), - ), - ], - ), + // TabBar( + // controller: _tabController_new, + // indicatorWeight: 3.0, + // indicatorSize: TabBarIndicatorSize.tab, + // labelColor: Color(0xff2B353E), + // unselectedLabelColor: Color(0xff575757), + // labelPadding: EdgeInsets.only(top: 15, bottom: 13, left: 20, right: 20), + // labelStyle: TextStyle( + // fontSize: 16, + // fontWeight: FontWeight.w600, + // letterSpacing: -0.48, + // ), + // unselectedLabelStyle: TextStyle( + // fontSize: 16, + // fontWeight: FontWeight.w600, + // letterSpacing: -0.48, + // ), + // onTap: (int value) { + // print(value); + // setState(() {}); + // }, + // tabs: [ + // Text( + // TranslationBase.of(context).outpatient, + // style: TextStyle(fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins'), + // ), + // Text( + // TranslationBase.of(context).inPatient, + // style: TextStyle(fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins'), + // ), + // ], + // ), if (model.user != null) Expanded( - child: - TabBarView( - physics: BouncingScrollPhysics(), - controller: _tabController_new, - children: [ + child: TabBarView( + physics: BouncingScrollPhysics(), + controller: _tabController_new, + children: [ Container( - child: Column( - children: [ - Padding( - padding: EdgeInsets.all(21), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - myRadioButton(TranslationBase.of(context).requested, 0), - myRadioButton(TranslationBase.of(context).ready, 1), - myRadioButton(TranslationBase.of(context).cancelled, 2), - ], - ), + child: Column( + children: [ + Padding( + padding: EdgeInsets.all(21), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + myRadioButton(TranslationBase.of(context).requested, 0), + myRadioButton(TranslationBase.of(context).ready, 1), + myRadioButton(TranslationBase.of(context).cancelled, 2), + ], + ), + ), + Expanded( + child: IndexedStack( + index: _currentPage, + children: [ + ReportListWidget(reportList: model.reportsOrderRequestList, emailAddress: model.user.emailAddress), + ReportListWidget(reportList: model.reportsOrderReadyList, emailAddress: model.user.emailAddress), + ReportListWidget(reportList: model.reportsOrderCanceledList, emailAddress: model.user.emailAddress), + ], + ), + ) + ], ), - Expanded( - child: IndexedStack( - index: _currentPage, - children: [ - ReportListWidget(reportList: model.reportsOrderRequestList, emailAddress: model.user.emailAddress), - ReportListWidget(reportList: model.reportsOrderReadyList, emailAddress: model.user.emailAddress), - ReportListWidget(reportList: model.reportsOrderCanceledList, emailAddress: model.user.emailAddress), - ], - ), - ) - ], - ), - ), - // InPatient Medical Reports - Container( + ), + // InPatient Medical Reports + Container( child: model.admissionsMedicalReportList.isNotEmpty ? Column( children: [ @@ -249,20 +248,21 @@ class _HomeReportPageState extends State with SingleTickerProvid if (projectViewModel.havePrivilege(21) // && _tabController_new.index == 0 ) - Padding( - padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), - child: DefaultButton( - TranslationBase.of(context).requestMedicalReport.toLowerCase().capitalizeFirstofEach, - () => Navigator.push( - context, - FadePage( - page: MedicalReports(), - ), - ).then((value) { - model.getReports(); - }), - ), - ) + if (_tabController_new.index == 0) + Padding( + padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), + child: DefaultButton( + TranslationBase.of(context).requestMedicalReport.toLowerCase().capitalizeFirstofEach, + () => Navigator.push( + context, + FadePage( + page: MedicalReports(), + ), + ).then((value) { + model.getReports(); + }), + ), + ) ], ), ), diff --git a/lib/pages/medical/reports/report_list_widget.dart b/lib/pages/medical/reports/report_list_widget.dart index adaef00e..2809b317 100644 --- a/lib/pages/medical/reports/report_list_widget.dart +++ b/lib/pages/medical/reports/report_list_widget.dart @@ -117,23 +117,23 @@ class ReportListWidget extends StatelessWidget { if (reportList[index].status == 2) Row( children: [ - InkWell( - onTap: () { - getMedicalReportPDF(report); - }, - child: Padding( - padding: const EdgeInsets.only(right: 11.0, left: 11.0), - child: Text(TranslationBase.of(context).viewReport, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - fontStyle: FontStyle.italic, - color: CustomColors.accentColor, - letterSpacing: -0.48, - height: 18 / 12, - decoration: TextDecoration.underline)), - ), - ), + // InkWell( + // onTap: () { + // getMedicalReportPDF(report); + // }, + // child: Padding( + // padding: const EdgeInsets.only(right: 11.0, left: 11.0), + // child: Text(TranslationBase.of(context).viewReport, + // style: TextStyle( + // fontSize: 12, + // fontWeight: FontWeight.w600, + // fontStyle: FontStyle.italic, + // color: CustomColors.accentColor, + // letterSpacing: -0.48, + // height: 18 / 12, + // decoration: TextDecoration.underline)), + // ), + // ), IconButton( icon: Icon(Icons.email), color: Color(0xff28323A), diff --git a/lib/pages/paymentService/payment_service.dart b/lib/pages/paymentService/payment_service.dart index 5bcf4592..3c5cb01f 100644 --- a/lib/pages/paymentService/payment_service.dart +++ b/lib/pages/paymentService/payment_service.dart @@ -1,4 +1,4 @@ -import 'package:badges/badges.dart'; +import 'package:badges/badges.dart' as badge_import; import 'package:diplomaticquarterapp/Constants.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; @@ -95,11 +95,11 @@ class PaymentService extends StatelessWidget { ? Positioned( left: 8, top: 4, - child: Badge( + child: badge_import.Badge( toAnimate: false, elevation: 0, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, + position: badge_import.BadgePosition.topEnd(), + shape: badge_import.BadgeShape.circle, badgeColor: secondaryColor.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( @@ -111,11 +111,11 @@ class PaymentService extends StatelessWidget { : Positioned( right: 8, top: 4, - child: Badge( + child: badge_import.Badge( toAnimate: false, elevation: 0, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, + position: badge_import.BadgePosition.topEnd(), + shape: badge_import.BadgeShape.circle, badgeColor: secondaryColor.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 7d97239c..0a293818 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -12,6 +12,7 @@ import 'package:diplomaticquarterapp/models/Appointments/doctor_pre_post_image.d import 'package:diplomaticquarterapp/models/Appointments/laser_body_parts.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; +import 'package:diplomaticquarterapp/models/anicllary-orders/ancillary_orders_proc_list.dart'; import 'package:diplomaticquarterapp/models/apple_pay_request.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; @@ -484,7 +485,7 @@ class DoctorsListService extends BaseService { dynamic localRes; await baseAppClient.post(GET_PATIENT_SHARE, onSuccess: (response, statusCode) async { - localRes = response['OnlineCheckInAppointments'][0]; + localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: request); @@ -961,6 +962,7 @@ class DoctorsListService extends BaseService { Request req = appGlobal.getPublicRequest(); request = { "AdvanceNumber": advanceNumber, + "AdvanceNumber_VP": advanceNumber, "PaymentReferenceNumber": paymentReference, "AppointmentID": appointmentID, "VersionID": req.VersionID, @@ -1046,12 +1048,18 @@ class DoctorsListService extends BaseService { var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); authUser = data; } - var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); - Request req = appGlobal.getPublicRequest(); + + List procedureOrderIDs = []; + + selectedProcListAPI.forEach((element) { + procedureOrderIDs.add(element["ProcedureID"]); + }); + request = { "RequestAncillaryOrderInvoice": [ {"MemberID": 102, "ProjectID": projectID, "AppointmentNo": appointmentID, "OrderNo": orderNo, "AncillaryOrderInvoiceProcList": selectedProcListAPI} - ] + ], + "ProcedureOrderIds": procedureOrderIDs }; dynamic localRes; await baseAppClient.post(GENERATE_ANCILLARY_ORDERS_INVOICE, onSuccess: (response, statusCode) async { @@ -1368,7 +1376,8 @@ class DoctorsListService extends BaseService { } Future HIS_createAdvancePayment(AppoitmentAllHistoryResultList appo, String projectID, double payedAmount, String paymentReference, String paymentMethodName, dynamic patientType, - String patientName, dynamic patientID, BuildContext context) async { + String patientName, dynamic patientID, BuildContext context, + {bool isAncillaryOrder = false}) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); @@ -1400,6 +1409,8 @@ class DoctorsListService extends BaseService { "SessionID": "YckwoXhUmWBsnHKEKig", "isDentalAllowedBackend": false, "PatientTypeID": patientType, + "IsAncillaryOrder": isAncillaryOrder, + // "AncillaryProcedureList": ancillaryOrdersProcedureList, "PatientType": patientType }; dynamic localRes; @@ -1832,4 +1843,6 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } + + } diff --git a/lib/splashPage.dart b/lib/splashPage.dart index 5876ed99..04e1c3b5 100644 --- a/lib/splashPage.dart +++ b/lib/splashPage.dart @@ -54,6 +54,7 @@ class _SplashScreenState extends State { await _privilegeService.getPrivilege(); ProjectViewModel projectProvider = Provider.of(context, listen: false); projectProvider.setPrivilegeModelList(privilege: _privilegeService.privilegeModelList); + projectProvider.setVidaPlusProjectList(_privilegeService.vidaPlusProjectListModel); AppSharedPreferences().clear(); // Clearing Shared Preferences On App Launch AppSharedPreferences().setString(APP_LANGUAGE, projectProvider.isArabic ? "ar" : "en"); var themeNotifier = Provider.of(context, listen: false); diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 8d8f51ee..804cecdd 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2902,6 +2902,12 @@ class TranslationBase { String get sickLeaveAdmittedPatient => localizedValues["sickLeaveAdmittedPatient"][locale.languageCode]; String get dischargeDate => localizedValues["dischargeDate"][locale.languageCode]; String get selectAdmissionText => localizedValues["selectAdmissionText"][locale.languageCode]; + String get invalidEligibility => localizedValues["invalidEligibility"][locale.languageCode]; + String get invalidInsurance => localizedValues["invalidInsurance"][locale.languageCode]; + String get continueCash => localizedValues["continueCash"][locale.languageCode]; + String get updateInsuranceText => localizedValues["updateInsurance"][locale.languageCode]; + String get downloadReport => localizedValues["downloadReport"][locale.languageCode]; + String get habibCallCenter => localizedValues["habibCallCenter"][locale.languageCode]; } diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index ece5613d..75b11879 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:auto_size_text/auto_size_text.dart'; -import 'package:badges/badges.dart'; +import 'package:badges/badges.dart' as badge_import; import 'package:cached_network_image/cached_network_image.dart'; import 'package:connectivity/connectivity.dart'; import 'package:crypto/crypto.dart' as crypto; @@ -241,11 +241,11 @@ class Utils { ? Positioned( left: 8, top: 4, - child: Badge( + child: badge_import.Badge( toAnimate: false, elevation: 0, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, + position: badge_import.BadgePosition.topEnd(), + shape: badge_import.BadgeShape.circle, badgeColor: secondaryColor.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( @@ -259,11 +259,11 @@ class Utils { ? Positioned( right: 8, top: 4, - child: Badge( + child: badge_import.Badge( toAnimate: false, elevation: 0, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, + position: badge_import.BadgePosition.topEnd(), + shape: badge_import.BadgeShape.circle, badgeColor: secondaryColor.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( @@ -614,11 +614,11 @@ class Utils { ? Positioned( left: 8, top: 4, - child: Badge( + child: badge_import.Badge( toAnimate: false, elevation: 0, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, + position: badge_import.BadgePosition.topEnd(), + shape: badge_import.BadgeShape.circle, badgeColor: secondaryColor.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( @@ -632,11 +632,11 @@ class Utils { ? Positioned( right: 8, top: 4, - child: Badge( + child: badge_import.Badge( toAnimate: false, elevation: 0, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, + position: badge_import.BadgePosition.topEnd(), + shape: badge_import.BadgeShape.circle, badgeColor: secondaryColor.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( @@ -810,6 +810,16 @@ class Utils { return crypto.md5.convert(utf8.encode(input)).toString(); } + static bool isVidaPlusProject(ProjectViewModel projectViewModel, int projectID) { + bool isVidaPlus = false; + projectViewModel.vidaPlusProjectList.forEach((element) { + if (element.projectID == projectID) { + isVidaPlus = true; + } + }); + return isVidaPlus; + } + static String generateSignature() { } diff --git a/lib/widgets/AnimatedTextFields.dart b/lib/widgets/AnimatedTextFields.dart index b4ad5f65..3719f3c9 100644 --- a/lib/widgets/AnimatedTextFields.dart +++ b/lib/widgets/AnimatedTextFields.dart @@ -24,9 +24,9 @@ Interval _getInternalInterval( class AnimatedTextFormField extends StatefulWidget { AnimatedTextFormField({ - Key key, + Key? key, this.interval = const Interval(0.0, 1.0), - @required this.width, + required this.width, this.loadingController, this.inertiaController, this.inertiaDirection, @@ -47,35 +47,35 @@ class AnimatedTextFormField extends StatefulWidget { super(key: key); final Interval interval; - final AnimationController loadingController; - final AnimationController inertiaController; + final AnimationController? loadingController; + final AnimationController? inertiaController; final double width; final bool enabled; - final String labelText; - final Widget prefixIcon; - final Widget suffixIcon; - final TextInputType keyboardType; - final TextInputAction textInputAction; + final String? labelText; + final Widget? prefixIcon; + final Widget? suffixIcon; + final TextInputType? keyboardType; + final TextInputAction? textInputAction; final bool obscureText; - final TextEditingController controller; - final FocusNode focusNode; - final FormFieldValidator validator; - final ValueChanged onFieldSubmitted; - final FormFieldSetter onSaved; - final TextFieldInertiaDirection inertiaDirection; + final TextEditingController? controller; + final FocusNode? focusNode; + final FormFieldValidator? validator; + final ValueChanged? onFieldSubmitted; + final FormFieldSetter? onSaved; + final TextFieldInertiaDirection? inertiaDirection; @override _AnimatedTextFormFieldState createState() => _AnimatedTextFormFieldState(); } class _AnimatedTextFormFieldState extends State { - Animation scaleAnimation; - Animation sizeAnimation; - Animation suffixIconOpacityAnimation; + late Animation scaleAnimation; + late Animation sizeAnimation; + late Animation suffixIconOpacityAnimation; - Animation fieldTranslateAnimation; - Animation iconRotationAnimation; - Animation iconTranslateAnimation; + late Animation fieldTranslateAnimation; + late Animation iconRotationAnimation; + late Animation iconTranslateAnimation; @override void initState() { @@ -140,7 +140,7 @@ class _AnimatedTextFormFieldState extends State { begin: 48.0, end: widget.width, ).animate(CurvedAnimation( - parent: loadingController, + parent: loadingController!, curve: _getInternalInterval( .2, 1.0, interval.begin, interval.end, Curves.linearToEaseOut), reverseCurve: Curves.easeInExpo, @@ -194,13 +194,13 @@ class _AnimatedTextFormFieldState extends State { borderSide: new BorderSide(), ), labelText: widget.labelText, - prefixIcon: _buildInertiaAnimation(widget.prefixIcon), + prefixIcon: _buildInertiaAnimation(widget.prefixIcon!), suffixIcon: _buildInertiaAnimation(widget.loadingController != null ? FadeTransition( - opacity: suffixIconOpacityAnimation, - child: widget.suffixIcon, + opacity: suffixIconOpacityAnimation!, + child: widget.suffixIcon!, ) - : widget.suffixIcon), + : widget.suffixIcon!), ); } @@ -251,9 +251,9 @@ class _AnimatedTextFormFieldState extends State { class AnimatedPasswordTextFormField extends StatefulWidget { AnimatedPasswordTextFormField({ - Key key, + Key? key, this.interval = const Interval(0.0, 1.0), - @required this.animatedWidth, + required this.animatedWidth, this.loadingController, this.inertiaController, this.inertiaDirection, @@ -271,19 +271,19 @@ class AnimatedPasswordTextFormField extends StatefulWidget { super(key: key); final Interval interval; - final AnimationController loadingController; - final AnimationController inertiaController; + final AnimationController? loadingController; + final AnimationController? inertiaController; final double animatedWidth; final bool enabled; - final String labelText; - final TextInputType keyboardType; - final TextInputAction textInputAction; - final TextEditingController controller; - final FocusNode focusNode; - final FormFieldValidator validator; - final ValueChanged onFieldSubmitted; - final FormFieldSetter onSaved; - final TextFieldInertiaDirection inertiaDirection; + final String? labelText; + final TextInputType? keyboardType; + final TextInputAction? textInputAction; + final TextEditingController? controller; + final FocusNode? focusNode; + final FormFieldValidator? validator; + final ValueChanged? onFieldSubmitted; + final FormFieldSetter? onSaved; + final TextFieldInertiaDirection? inertiaDirection; @override _AnimatedPasswordTextFormFieldState createState() => diff --git a/lib/widgets/CounterView.dart b/lib/widgets/CounterView.dart index 6ba77c15..039ba757 100644 --- a/lib/widgets/CounterView.dart +++ b/lib/widgets/CounterView.dart @@ -11,11 +11,11 @@ class StepperView extends StatefulWidget { final int initialNumber; final int maxNumber; final int minNumber; - final StepperCallbackFuture counterCallback; - final Function increaseCallback; - final Function decreaseCallback; + final StepperCallbackFuture? counterCallback; + final Function? increaseCallback; + final Function? decreaseCallback; - StepperView({this.initialNumber = 1, this.minNumber = 1, this.maxNumber, @required this.counterCallback, this.increaseCallback, this.decreaseCallback, this.height = 25, @required this.foregroundColor, @required this.backgroundColor, this.buttonPadding = 1}){ + StepperView({this.initialNumber = 1, this.minNumber = 1, required this.maxNumber, @required this.counterCallback, this.increaseCallback, this.decreaseCallback, this.height = 25, required this.foregroundColor, required this.backgroundColor, this.buttonPadding = 1}){ assert((this.initialNumber >= this.minNumber && this.initialNumber <= this.maxNumber)); } @override @@ -23,15 +23,15 @@ class StepperView extends StatefulWidget { } class _StepperViewState extends State { - int _currentCount; - StepperCallbackFuture _counterCallback; - Function _increaseCallback; - Function _decreaseCallback; + late int _currentCount; + late StepperCallbackFuture _counterCallback; + late Function _increaseCallback; + late Function _decreaseCallback; @override void initState() { _currentCount = widget.initialNumber ?? 1; - _counterCallback = widget.counterCallback; + _counterCallback = widget.counterCallback!; _increaseCallback = widget.increaseCallback ?? () {}; _decreaseCallback = widget.decreaseCallback ?? () {}; super.initState(); @@ -52,7 +52,7 @@ class _StepperViewState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ _createDecrementButton( - (_currentCount > widget.minNumber) ? () => _decrement() : null, + ((_currentCount > widget.minNumber) ? () => _decrement() : null) as VoidCallback, ), Container( width: 25, @@ -69,7 +69,7 @@ class _StepperViewState extends State { ) ), _createIncrementButton( - (_currentCount < widget.maxNumber) ? () => _increment() : null + ((_currentCount < widget.maxNumber) ? () => _increment() : null) as VoidCallback ), ], ), @@ -77,7 +77,7 @@ class _StepperViewState extends State { } void _increment() async{ - doInc({@required bool can}){ + doInc({required bool can}){ if(can) setState(() { _currentCount++; @@ -98,7 +98,7 @@ class _StepperViewState extends State { } void _decrement() async{ - doDec({@required bool can}){ + doDec({required bool can}){ if(can) setState(() { _currentCount--; @@ -117,7 +117,7 @@ class _StepperViewState extends State { } } - Widget _createIncrementButton(Function onPressed,) { + Widget _createIncrementButton(VoidCallback onPressed,) { return Stack( children: [ RawMaterialButton( @@ -152,7 +152,7 @@ class _StepperViewState extends State { ); } - Widget _createDecrementButton(Function onPressed) { + Widget _createDecrementButton(VoidCallback onPressed) { return Stack( children: [ RawMaterialButton( diff --git a/lib/widgets/Loader/gif_loader_container.dart b/lib/widgets/Loader/gif_loader_container.dart index 75083d1a..f473d3ff 100644 --- a/lib/widgets/Loader/gif_loader_container.dart +++ b/lib/widgets/Loader/gif_loader_container.dart @@ -1,5 +1,6 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter_gifimage/flutter_gifimage.dart'; + import 'package:flutter/cupertino.dart'; +import 'package:flutter_gif/flutter_gif.dart'; + class GifLoaderContainer extends StatefulWidget { @override @@ -7,15 +8,16 @@ class GifLoaderContainer extends StatefulWidget { } class _GifLoaderContainerState extends State with TickerProviderStateMixin { - GifController controller1; + late FlutterGifController controller; + @override void initState() { - controller1 = GifController(vsync: this); + FlutterGifController controller= FlutterGifController(vsync: this); WidgetsBinding.instance.addPostFrameCallback((_) { try { - controller1.repeat(min: 0, max: 11, period: Duration(milliseconds: 750), reverse: true); + controller.repeat(min: 0, max: 11, period: Duration(milliseconds: 750), reverse: true); } catch (ex) {} }); super.initState(); @@ -23,7 +25,7 @@ class _GifLoaderContainerState extends State with TickerProv @override void dispose() { - controller1.dispose(); + controller.dispose(); super.dispose(); } @@ -34,7 +36,7 @@ class _GifLoaderContainerState extends State with TickerProv child: Container( // margin: EdgeInsets.only(bottom: 40), child: GifImage( - controller: controller1, + controller: controller, image: AssetImage("assets/images/progress-loading-red.gif"), //NetworkImage("http://img.mp.itc.cn/upload/20161107/5cad975eee9e4b45ae9d3c1238ccf91e.jpg"), ), )); diff --git a/lib/widgets/LoadingButton.dart b/lib/widgets/LoadingButton.dart index c0004112..8f94cdde 100644 --- a/lib/widgets/LoadingButton.dart +++ b/lib/widgets/LoadingButton.dart @@ -6,20 +6,20 @@ import 'package:flutter/rendering.dart'; class AnimatedButton extends StatefulWidget { AnimatedButton({ - Key key, - @required this.text, - @required this.onPressed, - @required this.controller, + Key? key, + required this.text, + required this.onPressed, + required this.controller, this.textColor, - this.loadingColor, + required this.loadingColor, this.color, }) : super(key: key); final String text; - final Color color; - final Color textColor; + final Color? color; + final Color? textColor; final Color loadingColor; - final Function onPressed; + final VoidCallback? onPressed; final AnimationController controller; @override @@ -28,18 +28,18 @@ class AnimatedButton extends StatefulWidget { class _AnimatedButtonState extends State with SingleTickerProviderStateMixin { - Animation _sizeAnimation; - Animation _textOpacityAnimation; - Animation _buttonOpacityAnimation; - Animation _ringThicknessAnimation; - Animation _ringOpacityAnimation; - Animation _colorAnimation; + late Animation _sizeAnimation; + late Animation _textOpacityAnimation; + late Animation _buttonOpacityAnimation; + late Animation _ringThicknessAnimation; + late Animation _ringOpacityAnimation; + late Animation _colorAnimation; var _isLoading = false; var _hover = false; var _width = 120.0; - Color _color; - Color _loadingColor; + late Color _color; + late Color _loadingColor; static const _height = 40.0; static const _loadingCircleRadius = _height / 2; @@ -91,10 +91,11 @@ class _AnimatedButtonState extends State final theme = Theme.of(context); final buttonTheme = theme.floatingActionButtonTheme; - _color = widget.color ?? buttonTheme.backgroundColor; - _loadingColor = widget.loadingColor ?? theme.accentColor; + _color = (widget.color ?? buttonTheme.backgroundColor)!; + _loadingColor = widget.loadingColor ?? theme.colorScheme.secondary; _colorAnimation = ColorTween( + begin: _color, end: _loadingColor, ).animate( @@ -137,14 +138,14 @@ class _AnimatedButtonState extends State /// sets width and size animation void _updateWidth() { final theme = Theme.of(context); - final fontSize = theme.textTheme.button.fontSize; + final fontSize = theme.textTheme.button!.fontSize; final renderParagraph = RenderParagraph( TextSpan( text: widget.text, style: TextStyle( fontSize: fontSize, - fontWeight: theme.textTheme.button.fontWeight, - letterSpacing: theme.textTheme.button.letterSpacing, + fontWeight: theme.textTheme.button!.fontWeight, + letterSpacing: theme.textTheme.button!.letterSpacing, ), ), textDirection: TextDirection.ltr, @@ -155,7 +156,7 @@ class _AnimatedButtonState extends State // text width based on fontSize, plus 45.0 for padding var textWidth = - renderParagraph.getMinIntrinsicWidth(fontSize).ceilToDouble() + 45.0; + renderParagraph.getMinIntrinsicWidth(fontSize!).ceilToDouble() + 45.0; // button width is min 120.0 and max 240.0 _width = textWidth > 120.0 && textWidth < 240.0 @@ -196,14 +197,14 @@ class _AnimatedButtonState extends State color: _colorAnimation.value, child: child, shadowColor: _color, - elevation: !_isLoading - ? (_hover - ? buttonTheme.highlightElevation - : buttonTheme.elevation) - : 0, + elevation: (_isLoading == false) + ? (_hover == true + ? buttonTheme.highlightElevation ?? 0.0 + : buttonTheme.elevation ?? 0.0) + : 0.0, ), child: InkWell( - onTap: !_isLoading ? widget.onPressed : null, + onTap: !_isLoading ? widget!.onPressed : null, splashColor: buttonTheme.splashColor, customBorder: buttonTheme.shape, onHighlightChanged: (value) => setState(() => _hover = value), @@ -235,7 +236,7 @@ class _AnimatedButtonState extends State child: AnimatedBuilder( animation: _ringThicknessAnimation, builder: (context, child) => Ring( - color: widget.loadingColor, + color: widget!.loadingColor, size: _height, thickness: _ringThicknessAnimation.value, ), @@ -259,8 +260,8 @@ class _AnimatedButtonState extends State class Ring extends StatelessWidget { Ring({ - Key key, - this.color, + Key? key, + required this.color, this.size = 40.0, this.thickness = 2.0, this.value = 1.0, @@ -294,9 +295,9 @@ enum AnimatedTextRotation { up, down } /// https://medium.com/flutter-community/flutter-challenge-3d-bottom-navigation-bar-48952a5fd996 class AnimatedText extends StatefulWidget { AnimatedText({ - Key key, - @required this.text, - this.style, + Key? key, + required this.text, + required this.style, this.textRotation = AnimatedTextRotation.up, }) : super(key: key); @@ -315,8 +316,8 @@ class _AnimatedTextState extends State var _layoutHeight = 0.0; final _textKey = GlobalKey(); - Animation _animation; - AnimationController _controller; + late Animation _animation; + late AnimationController _controller; double get radius => _layoutHeight / 2; @@ -337,7 +338,7 @@ class _AnimatedTextState extends State _oldText = widget.text; WidgetsBinding.instance.addPostFrameCallback((_) { - setState(() => _layoutHeight = getWidgetSize(_textKey)?.height); + setState(() => _layoutHeight = getWidgetSize(_textKey)!.height); }); } @@ -458,8 +459,8 @@ class _AnimatedTextState extends State double lerp(double start, double end, double percent) => (start + percent * (end - start)); - Size getWidgetSize(GlobalKey key) { - final RenderBox renderBox = key.currentContext?.findRenderObject(); - return renderBox?.size; + Size? getWidgetSize(GlobalKey key) { + return key.currentContext!.size; + //return renderBox?.size; } } diff --git a/lib/widgets/app_map/google_huawei_map.dart b/lib/widgets/app_map/google_huawei_map.dart index 35eabfdc..1f7aed92 100644 --- a/lib/widgets/app_map/google_huawei_map.dart +++ b/lib/widgets/app_map/google_huawei_map.dart @@ -3,32 +3,34 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart' as googlemap; // import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; +import 'package:huawei_map/components/callbacks.dart'; +import 'package:huawei_map/components/cameraPosition.dart' as cameraposition; import 'package:huawei_map/map.dart' as hmsMap; class AppMap extends StatefulWidget { - CameraPositionCallback onCameraMove; - Map initialCamera; + late CameraPositionCallback? onCameraMove; + late Map initialCamera; - AppMapState _state; - Function onMapCreated; - Function onCameraIdle; + AppMapState? _state; + late Function? onMapCreated; + late Function? onCameraIdle; - AppMap(this.initialCamera, {this.onCameraMove, this.onMapCreated, this.onCameraIdle}); + AppMap(this.initialCamera, { this.onCameraMove, this.onMapCreated, this.onCameraIdle}); @override State createState() => _state = AppMapState(); - moveTo({@required CameraPosition cameraPostion}) { - if (_state.isHuawei) { - final cameraJson = cameraPostion.toMap(); + moveTo({ required CameraPosition cameraPostion}) { + if (_state!.isHuawei) { + final cameraJson = cameraPostion?.toMap(); final camera = hmsMap.CameraPosition.fromMap(cameraJson); - _state._huaweiMapController.animateCamera(hmsMap.CameraUpdate.newCameraPosition(camera)); + _state?._huaweiMapController.animateCamera(hmsMap.CameraUpdate.newCameraPosition(camera)); } else { - _state.googleMapController.animateCamera(CameraUpdate.newCameraPosition(cameraPostion)); + _state?.googleMapController.animateCamera(googlemap.CameraUpdate.newCameraPosition(cameraPostion! as googlemap.CameraPosition)); } } } @@ -36,13 +38,13 @@ class AppMap extends StatefulWidget { class AppMapState extends State { bool isHuawei = false; - Completer _googleMapControllerComp = Completer(); - GoogleMapController googleMapController; + Completer _googleMapControllerComp = Completer(); + late googlemap.GoogleMapController googleMapController; Completer _huaweiMapControllerComp = Completer(); - hmsMap.HuaweiMapController _huaweiMapController; + late hmsMap.HuaweiMapController _huaweiMapController; - HmsApiAvailability hmsApiAvailability; + late HmsApiAvailability hmsApiAvailability; checkIsHuawei() async { await hmsApiAvailability.isHMSAvailable().then((value) { @@ -69,19 +71,22 @@ class AppMapState extends State { Widget map() => isHuawei ? huaweiMap() : googleMap(); Widget googleMap() { - return GoogleMap( - mapType: MapType.normal, + return googlemap.GoogleMap( + mapType: googlemap.MapType.normal, zoomControlsEnabled: true, myLocationButtonEnabled: true, myLocationEnabled: true, - initialCameraPosition: CameraPosition.fromMap(widget.initialCamera), - onCameraMove: widget.onCameraMove, - onMapCreated: (GoogleMapController controller) { + initialCameraPosition: googlemap.CameraPosition.fromMap(widget.initialCamera), + onCameraMove: widget.onCameraMove, + onMapCreated: (googlemap.GoogleMapController controller) { googleMapController = controller; _googleMapControllerComp.complete(controller); - widget.onMapCreated(); + widget.onMapCreated!(); + }, + onCameraIdle: () { + print("onCameraIdle"); + widget.onCameraIdle!(); }, - onCameraIdle: widget.onCameraIdle, ); } @@ -92,15 +97,15 @@ class AppMapState extends State { myLocationButtonEnabled: true, myLocationEnabled: true, initialCameraPosition: hmsMap.CameraPosition.fromMap(widget.initialCamera), - onCameraMove: (camera) => widget.onCameraMove(CameraPosition.fromMap(camera.toMap())), + onCameraMove: (camera) => widget.onCameraMove!(CameraPosition.fromMap(camera.toMap())), onMapCreated: (controller) { _huaweiMapController = controller; _huaweiMapControllerComp.complete(controller); - widget.onMapCreated(); + widget.onMapCreated!(); }, onCameraIdle: () { print("onCameraIdle"); - widget.onCameraIdle(); + widget.onCameraIdle!(); }, ); } diff --git a/lib/widgets/bottom_navigation/bottom_navigation_item.dart b/lib/widgets/bottom_navigation/bottom_navigation_item.dart index ff085dd9..f7cdafce 100644 --- a/lib/widgets/bottom_navigation/bottom_navigation_item.dart +++ b/lib/widgets/bottom_navigation/bottom_navigation_item.dart @@ -1,4 +1,4 @@ -import 'package:badges/badges.dart'; +import 'package:badges/badges.dart' as badge_import; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; @@ -106,10 +106,10 @@ class BottomNavigationItem extends StatelessWidget { Positioned( right: 18.0, bottom: 28.0, - child: Badge( + child: badge_import.Badge( toAnimate: false, - position: BadgePosition.topEnd(), - shape: BadgeShape.circle, + position: badge_import.BadgePosition.topEnd(), + shape: badge_import.BadgeShape.circle, badgeColor: secondaryColor.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( diff --git a/lib/widgets/data_display/CarouselSlider.dart b/lib/widgets/data_display/CarouselSlider.dart index b8af33ac..29538933 100644 --- a/lib/widgets/data_display/CarouselSlider.dart +++ b/lib/widgets/data_display/CarouselSlider.dart @@ -1,22 +1,23 @@ -import 'package:carousel_pro/carousel_pro.dart'; + +import 'package:carousel_pro_nullsafety/carousel_pro_nullsafety.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; class CarouselSlider extends StatelessWidget { const CarouselSlider({ - @required this.imagesUrlList, - @required this.width, - @required this.height, + required this.imagesUrlList, + required this.width, + required this.height, this.onImageChange, this.autoPlay = false, - Key key, + Key? key, }) : super(key: key); final List imagesUrlList; final double height; final double width; final bool autoPlay; - final Function onImageChange; + final void Function(int?, int)? onImageChange; @override Widget build(BuildContext context) { return Carousel( @@ -37,7 +38,7 @@ class CarouselSlider extends StatelessWidget { return Builder(builder: (BuildContext context) { return Container( child: Image.network(image, loadingBuilder: (BuildContext context, - Widget child, ImageChunkEvent loadingProgress) { + Widget child, ImageChunkEvent? loadingProgress) { if (loadingProgress == null) return child; return Center( child: SizedBox( diff --git a/lib/widgets/data_display/medical/LabResult/LineChartCurved.dart b/lib/widgets/data_display/medical/LabResult/LineChartCurved.dart index 992e5659..feea3a00 100644 --- a/lib/widgets/data_display/medical/LabResult/LineChartCurved.dart +++ b/lib/widgets/data_display/medical/LabResult/LineChartCurved.dart @@ -5,8 +5,8 @@ import 'package:flutter/material.dart'; import '../../../../core/model/labs/LabOrderResult.dart'; class LineChartCurved extends StatefulWidget { - final String title; - final List labResult; + final String? title; + final List? labResult; LineChartCurved({this.title, this.labResult}); @@ -15,8 +15,8 @@ class LineChartCurved extends StatefulWidget { } class LineChartCurvedState extends State { - bool isShowingMainData; - List xAxixs = List(); + bool? isShowingMainData; + List xAxixs = []; int indexes = 0; @override @@ -27,10 +27,10 @@ class LineChartCurvedState extends State { } getXaxix() { - indexes = widget.labResult.length ~/ 3.5; - for (int index = 0; index < widget.labResult.length; index++) { + indexes = widget.labResult!.length ~/ 3.5; + for (int index = 0; index < widget.labResult!.length; index++) { int mIndex = indexes * index; - if (mIndex < widget.labResult.length) { + if (mIndex < widget.labResult!.length) { xAxixs.add(mIndex); } } @@ -49,7 +49,7 @@ class LineChartCurvedState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.title, + widget.title!, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), ), SizedBox(height: 16), diff --git a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart index d54249da..3436523d 100644 --- a/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart +++ b/lib/widgets/data_display/medical/LabResult/laboratory_result_widget.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/header_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/new_design/doctor_header.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/cupertino.dart'; @@ -35,7 +36,7 @@ class _LaboratoryResultWidgetState extends State { Widget build(BuildContext context) { projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getPatientLabResult(patientLabOrder: widget.patientLabOrder), + onModelReady: (model) => model.getPatientLabResult(isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrder.projectID)), patientLabOrder: widget.patientLabOrder), builder: (_, model, w) => NetworkBaseView( baseViewModel: model, child: Column( diff --git a/lib/widgets/data_display/medical/doctor_card.dart b/lib/widgets/data_display/medical/doctor_card.dart index 20b2714e..c91a17b7 100644 --- a/lib/widgets/data_display/medical/doctor_card.dart +++ b/lib/widgets/data_display/medical/doctor_card.dart @@ -8,27 +8,27 @@ import 'package:flutter/material.dart'; import 'package:flutter_countdown_timer/countdown_timer_controller.dart'; import 'package:flutter_countdown_timer/current_remaining_time.dart'; import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; import '../../my_rich_text.dart'; class DoctorCard extends StatelessWidget { - final String name; - final String subName; - final double rating; - final DateTime date; - final String profileUrl; - final String billNo; - final Function onTap; - final Function onEmailTap; - final bool isInOutPatient; - final bool isShowInOutPatient; - final bool isLiveCareAppointment; - final bool isSortByClinic; - final String appointmentTime; - final bool isParentAppointment; - final int remainingTimeInMinutes; + final String? name; + final String? subName; + final double? rating; + final DateTime? date; + final String? profileUrl; + final String? billNo; + final VoidCallback? onTap; + final VoidCallback? onEmailTap; + final bool? isInOutPatient; + final bool? isShowInOutPatient; + final bool? isLiveCareAppointment; + final bool? isSortByClinic; + final String? appointmentTime; + final bool? isParentAppointment; + final int? remainingTimeInMinutes; final String vaccineName; final bool isSickLeave; final int sickLeaveStatus; @@ -53,7 +53,7 @@ class DoctorCard extends StatelessWidget { this.isSickLeave = false, this.sickLeaveStatus = 0}); - ProjectViewModel projectViewModel; + ProjectViewModel? projectViewModel; @override Widget build(BuildContext context) { @@ -84,29 +84,29 @@ class DoctorCard extends StatelessWidget { height: double.infinity, alignment: Alignment.center, padding: EdgeInsets.only(left: 2, right: 2), - decoration: isShowInOutPatient + decoration: isShowInOutPatient! ? BoxDecoration( //Colors.red[900] Color(0xff404545) - color: isLiveCareAppointment + color: isLiveCareAppointment! ? Color(0xff2E303A) - : !isInOutPatient + : !isInOutPatient! ? Color(0xffD02127) : Color(0xffa9a089), borderRadius: BorderRadius.only( - topLeft: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10), - bottomLeft: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10), - topRight: projectViewModel.isArabic ? Radius.circular(10) : Radius.circular(0), - bottomRight: projectViewModel.isArabic ? Radius.circular(10) : Radius.circular(0), + topLeft: projectViewModel!.isArabic ? Radius.circular(0) : Radius.circular(10), + bottomLeft: projectViewModel!.isArabic ? Radius.circular(0) : Radius.circular(10), + topRight: projectViewModel!.isArabic ? Radius.circular(10) : Radius.circular(0), + bottomRight: projectViewModel!.isArabic ? Radius.circular(10) : Radius.circular(0), ), ) : BoxDecoration(), - child: isShowInOutPatient + child: isShowInOutPatient! ? RotatedBox( quarterTurns: 3, child: Text( - isLiveCareAppointment + isLiveCareAppointment! ? TranslationBase.of(context).liveCare.toLowerCase().capitalizeFirstofEach - : !isInOutPatient + : !isInOutPatient! ? TranslationBase.of(context).inPatient.toLowerCase().capitalizeFirstofEach : TranslationBase.of(context).outpatient.toLowerCase().capitalizeFirstofEach, style: TextStyle(fontSize: 10, fontWeight: FontWeight.w700, color: Colors.white, letterSpacing: -0.2, height: 16 / 10), @@ -146,7 +146,7 @@ class DoctorCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( - DateUtil.getDayMonthYearDateFormatted(date), + DateUtil.getDayMonthYearDateFormatted(date!), style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12), ), Text( @@ -163,8 +163,8 @@ class DoctorCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ LargeAvatar( - name: name, - url: profileUrl, + name: name!, + url: profileUrl!, width: 48, height: 48, ), @@ -175,33 +175,45 @@ class DoctorCard extends StatelessWidget { mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - MyRichText(isSortByClinic ? TranslationBase.of(context).branch : TranslationBase.of(context).clinic + ":", subName, projectViewModel.isArabic), + MyRichText(isSortByClinic! ? TranslationBase.of(context).branch : TranslationBase.of(context).clinic + ":", subName!, projectViewModel!.isArabic), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - if (rating == null && billNo != "") MyRichText(TranslationBase.of(context).invoiceNo, billNo ?? "", projectViewModel.isArabic), - if (vaccineName != "") MyRichText("", vaccineName ?? "", projectViewModel.isArabic), + if (rating == null && billNo != "") MyRichText(TranslationBase.of(context).invoiceNo, billNo ?? "", projectViewModel!.isArabic), + if (vaccineName != "") MyRichText("", vaccineName ?? "", projectViewModel!.isArabic), if (rating != null) Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: [ - RatingBar.readOnly( - initialRating: rating, - size: 16.0, - filledColor: Color(0XFFD02127), - emptyColor: Color(0XFFD02127), - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star_border, - ), + // RatingBar.readOnly( + // initialRating: rating, + // size: 16.0, + // filledColor: Color(0XFFD02127), + // emptyColor: Color(0XFFD02127), + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: Icons.star, + // emptyIcon: Icons.star_border, + // ), + RatingBar( + initialRating: rating!, + // size: 18.0, + // filledColor: Color(0XFFD02127), + // emptyColor: Color(0XFFD02127), + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: Icons.star, + // emptyIcon: , + // + ratingWidget: RatingWidget( full:Icon(Icons.star, color:Color(0XFFD02127)), half:Icon(Icons.star_half, color: Color(0XFFD02127)), empty: Icon(Icons.star_border,color: Color(0XFFD02127)) , + ), onRatingUpdate: (double value) { }), ], ), if (remainingTimeInMinutes != null) CountdownTimer( - controller: CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + (remainingTimeInMinutes * 1000) * 60), - widgetBuilder: (_, CurrentRemainingTime time) { + controller: CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + (remainingTimeInMinutes! * 1000) * 60), + widgetBuilder: (_, CurrentRemainingTime? time) { return time != null ? Text( "${time.days ?? 0}:${time.hours ?? 0}:${time.min}:${time.sec}", @@ -219,7 +231,7 @@ class DoctorCard extends StatelessWidget { height: 48, child: Align( alignment: Alignment.bottomCenter, - child: (onEmailTap != null && projectViewModel.havePrivilege(17)) + child: (onEmailTap != null && projectViewModel!.havePrivilege(17)) ? InkWell( onTap: onEmailTap, child: Icon( diff --git a/lib/widgets/data_display/medical/medical_profile_item.dart b/lib/widgets/data_display/medical/medical_profile_item.dart index cfe7f59f..561236f1 100644 --- a/lib/widgets/data_display/medical/medical_profile_item.dart +++ b/lib/widgets/data_display/medical/medical_profile_item.dart @@ -11,11 +11,11 @@ class MedicalProfileItem extends StatelessWidget { final bool hasBadge = false; final bool isPngImage; bool isEnable; - Color imgColor; + Color? imgColor; final width; final height; - MedicalProfileItem({@required this.imagePath, @required this.title, @required this.subTitle, hasBadge, this.isEnable = true, this.imgColor, this.isPngImage = false, this.width, this.height}); + MedicalProfileItem({required this.imagePath, required this.title, required this.subTitle, hasBadge, this.isEnable = true, this.imgColor, this.isPngImage = false, this.width, this.height}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/data_display/medical/time_line_new_widget.dart b/lib/widgets/data_display/medical/time_line_new_widget.dart index 0f5f9195..65ff243b 100644 --- a/lib/widgets/data_display/medical/time_line_new_widget.dart +++ b/lib/widgets/data_display/medical/time_line_new_widget.dart @@ -35,7 +35,7 @@ class TimeLineView extends StatefulWidget { class _TimeLineViewState extends State { List tempList = []; List dateObjs = []; - DateObj selectedDateObj = null; + late DateObj selectedDateObj; final authService = new auth.AuthProvider(); @override @@ -148,8 +148,8 @@ class _TimeLineViewState extends State { ); }).toList(), onChanged: (r) { - selectedDateObj = r; - applyFilter(r.year == 0 ? true : false); + selectedDateObj = r!; + applyFilter(r?.year == 0 ? true : false); setState(() {}); }, underline: Container( @@ -236,7 +236,7 @@ class _TimeLineViewState extends State { fontWeight: FontWeight.bold, fontSize: 14, letterSpacing: -0.42, - ), + ), ), mHeight(4), !isLogged @@ -244,7 +244,7 @@ class _TimeLineViewState extends State { height: MediaQuery.of(context).size.width / 14, width: MediaQuery.of(context).size.width / (widget.isArabic ? 4 : 6), child: CustomTextButton( - shape: cardRadiusNew(8), + // shape: cardRadiusNew(8), elevation: 0, backgroundColor: Color(0xFFFBF2E31), onPressed: () { @@ -307,10 +307,10 @@ class _TimeLineViewState extends State { } class TimelineNewWidget extends StatelessWidget { - bool isLast; - final AppoitmentAllHistoryResultList appoitmentAllHistoryResul; + bool? isLast; + final AppoitmentAllHistoryResultList? appoitmentAllHistoryResul; - TimelineNewWidget({Key key, this.appoitmentAllHistoryResul, this.isLast}); + TimelineNewWidget({Key? key, this.appoitmentAllHistoryResul, this.isLast}); @override Widget build(BuildContext context) { @@ -327,7 +327,7 @@ class TimelineNewWidget extends StatelessWidget { children: [ Text( DateUtil.getDayMonthYearLangDateFormatted( - DateUtil.convertStringToDate(appoitmentAllHistoryResul.appointmentDate), + DateUtil.convertStringToDate(appoitmentAllHistoryResul!.appointmentDate), projectViewModel.isArabic ? "ar" : "en", ), style: TextStyle( @@ -337,7 +337,7 @@ class TimelineNewWidget extends StatelessWidget { ), ), mWidth(8), - isLast ? Container() : barView(), + isLast! ? Container() : barView(), ], ), ), @@ -349,20 +349,20 @@ class TimelineNewWidget extends StatelessWidget { context, FadePage( page: AppointmentDetails( - appo: appoitmentAllHistoryResul, + appo: appoitmentAllHistoryResul!, parentIndex: 2, ))); }, - name: appoitmentAllHistoryResul.doctorNameObj, + name: appoitmentAllHistoryResul!.doctorNameObj, disableProfileView: false, - url: appoitmentAllHistoryResul.doctorImageURL, + url: appoitmentAllHistoryResul!.doctorImageURL, width: 30, height: 30, isAppointmentAvatar: true, ), mHeight(6), Text( - appoitmentAllHistoryResul.doctorNameObj, + appoitmentAllHistoryResul!.doctorNameObj, style: TextStyle( color: CustomColors.white, fontSize: 10, @@ -371,7 +371,7 @@ class TimelineNewWidget extends StatelessWidget { ), ), Text( - appoitmentAllHistoryResul.clinicName, + appoitmentAllHistoryResul!.clinicName, style: TextStyle( color: CustomColors.grey2, fontSize: 10, diff --git a/lib/widgets/data_display/medical/time_line_widget.dart b/lib/widgets/data_display/medical/time_line_widget.dart index 11d2394f..6027f2a9 100644 --- a/lib/widgets/data_display/medical/time_line_widget.dart +++ b/lib/widgets/data_display/medical/time_line_widget.dart @@ -11,10 +11,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class TimeLineWidget extends StatelessWidget { - final bool isUp; - final AppoitmentAllHistoryResultList appoitmentAllHistoryResul; + final bool? isUp; + final AppoitmentAllHistoryResultList? appoitmentAllHistoryResul; - TimeLineWidget({Key key, this.isUp, this.appoitmentAllHistoryResul}); + TimeLineWidget({Key? key, this.isUp, this.appoitmentAllHistoryResul}); @override Widget build(BuildContext context) { @@ -33,7 +33,7 @@ class TimeLineWidget extends StatelessWidget { ), ), ), - if (isUp) + if (isUp!) Positioned( top: projectViewModel.isArabic ? 15 : 18, child: Container( @@ -41,7 +41,7 @@ class TimeLineWidget extends StatelessWidget { child: Column( children: [ Texts( - appoitmentAllHistoryResul.doctorNameObj, + appoitmentAllHistoryResul?.doctorNameObj, color: Colors.white, fontSize: 10.5, fontWeight: FontWeight.normal, @@ -57,13 +57,12 @@ class TimeLineWidget extends StatelessWidget { context, FadePage( page: AppointmentDetails( - appo: appoitmentAllHistoryResul, + appo: appoitmentAllHistoryResul!, ), ), ); }, - name: appoitmentAllHistoryResul.doctorNameObj, - url: appoitmentAllHistoryResul.doctorImageURL, + name: appoitmentAllHistoryResul!.doctorImageURL, width: 30, height: 30, ), @@ -77,7 +76,7 @@ class TimeLineWidget extends StatelessWidget { height: 15, decoration: BoxDecoration( color: Colors.yellow[700], - border: Border.all(color: Colors.yellow[700], width: 2), + border: Border.all(color: Colors.yellow[700]!, width: 2), shape: BoxShape.rectangle, borderRadius: BorderRadius.all( Radius.circular(25.0), @@ -88,13 +87,13 @@ class TimeLineWidget extends StatelessWidget { height: 4, ), Texts( - DateUtil.getMonthDayYearLangDateFormatted(DateUtil.convertStringToDate(appoitmentAllHistoryResul.appointmentDate), projectViewModel.isArabic ? "ar" : "en"), + DateUtil.getMonthDayYearLangDateFormatted(DateUtil.convertStringToDate(appoitmentAllHistoryResul!.appointmentDate), projectViewModel.isArabic ? "ar" : "en"), color: Colors.white, fontSize: 12.5, fontWeight: FontWeight.normal, ), Texts( - appoitmentAllHistoryResul.clinicName, + appoitmentAllHistoryResul!.clinicName, color: Colors.white, fontSize: 12.5, fontWeight: FontWeight.normal, @@ -111,13 +110,13 @@ class TimeLineWidget extends StatelessWidget { child: Column( children: [ Texts( - appoitmentAllHistoryResul.clinicName.trim(), + appoitmentAllHistoryResul!.clinicName.trim(), color: Colors.white, fontSize: 12.5, fontWeight: FontWeight.normal, ), Texts( - DateUtil.getMonthDayYearLangDateFormatted(DateUtil.convertStringToDate(appoitmentAllHistoryResul.appointmentDate), projectViewModel.isArabic ? "ar" : "en"), + DateUtil.getMonthDayYearLangDateFormatted(DateUtil.convertStringToDate(appoitmentAllHistoryResul!.appointmentDate), projectViewModel.isArabic ? "ar" : "en"), color: Colors.white, fontSize: 12.5, fontWeight: FontWeight.normal, @@ -130,7 +129,7 @@ class TimeLineWidget extends StatelessWidget { height: 15, decoration: BoxDecoration( color: Colors.yellow[700], - border: Border.all(color: Colors.yellow[700], width: 2), + border: Border.all(color: Colors.yellow[700]!, width: 2), shape: BoxShape.rectangle, borderRadius: BorderRadius.all( Radius.circular(25.0), @@ -148,11 +147,11 @@ class TimeLineWidget extends StatelessWidget { context, FadePage( page: AppointmentDetails( - appo: appoitmentAllHistoryResul, + appo: appoitmentAllHistoryResul!, ))); }, - name: appoitmentAllHistoryResul.doctorNameObj, - url: appoitmentAllHistoryResul.doctorImageURL, + name: appoitmentAllHistoryResul!.doctorNameObj, + url: appoitmentAllHistoryResul!.doctorImageURL, width: 30, height: 30, ), @@ -160,7 +159,7 @@ class TimeLineWidget extends StatelessWidget { height: 3, ), Texts( - appoitmentAllHistoryResul.doctorNameObj.trim(), + appoitmentAllHistoryResul!.doctorNameObj.trim(), color: Colors.white, fontSize: 10.5, fontWeight: FontWeight.normal, diff --git a/lib/widgets/data_display/services)contaniner.dart b/lib/widgets/data_display/services)contaniner.dart index cab74172..e18507f4 100644 --- a/lib/widgets/data_display/services)contaniner.dart +++ b/lib/widgets/data_display/services)contaniner.dart @@ -2,20 +2,20 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; class ServicesContainer extends StatelessWidget { - final String title; - final String imageLocation; - final Function onTap; + final String? title; + final String? imageLocation; + final VoidCallback? onTap; ServicesContainer({this.title, this.imageLocation, this.onTap}); @override Widget build(BuildContext context) { return InkWell( - onTap: () => onTap(), + onTap: () => onTap!(), child: Container( height: 60, margin: EdgeInsets.all(8), decoration: BoxDecoration( - color: Theme.of(context).textTheme.headline2.color, + color: Theme.of(context).textTheme.headline2!.color, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(7), ), @@ -28,7 +28,7 @@ class ServicesContainer extends StatelessWidget { Row( children: [ Image.asset( - imageLocation, + imageLocation!, height: 30, width: 40, ), diff --git a/lib/widgets/data_display/text.dart b/lib/widgets/data_display/text.dart index 4b9ac2f9..498e5e48 100644 --- a/lib/widgets/data_display/text.dart +++ b/lib/widgets/data_display/text.dart @@ -3,38 +3,38 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class Texts extends StatefulWidget { - final String text; - final String variant; - final Color color; - final bool bold; - final bool regular; - final bool medium; - final int maxLength; - final bool italic; - final TextAlign textAlign; - final int maxLines; - final bool readMore; - final String style; - final bool allowExpand; - final double fontSize; - final FontWeight fontWeight; - final double margin; - final double marginTop; - final double marginRight; - final double marginBottom; - final double marginLeft; - final TextDecoration decoration; - final double heightFactor; + final String? text; + final String? variant; + final Color? color; + final bool? bold; + final bool? regular; + final bool? medium; + final int? maxLength; + final bool? italic; + final TextAlign? textAlign; + final int? maxLines; + final bool? readMore; + final String? style; + final bool? allowExpand; + final double? fontSize; + final FontWeight? fontWeight; + final double? margin; + final double? marginTop; + final double? marginRight; + final double? marginBottom; + final double? marginLeft; + final TextDecoration? decoration; + final double? heightFactor; Texts(this.text, - {Key key, + {Key? key, this.variant, this.color, this.bold, this.regular, this.medium, this.allowExpand = true, - this.italic: false, + this.italic= false, this.textAlign, this.maxLength = 60, this.maxLines, @@ -63,9 +63,9 @@ class _TextsState extends State { void didUpdateWidget(Texts oldWidget) { setState(() { if (widget.style == "overline") - text = widget.text.toUpperCase(); + text = widget.text!.toUpperCase(); else { - text = widget.text; + text = widget.text!; } }); super.didUpdateWidget(oldWidget); @@ -73,11 +73,11 @@ class _TextsState extends State { @override void initState() { - hidden = widget.readMore; + hidden = widget.readMore!; if (widget.style == "overline") - text = widget.text.toUpperCase(); + text = widget.text!.toUpperCase(); else { - text = widget.text; + text = widget.text!; } super.initState(); } @@ -119,7 +119,7 @@ class _TextsState extends State { } } - FontWeight _getFontWeight() { + FontWeight? _getFontWeight() { if (widget.bold ?? false) { return FontWeight.w900; } else if (widget.regular ?? false) { @@ -169,7 +169,7 @@ class _TextsState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - TextStyle _getFontStyle() { + TextStyle? _getFontStyle() { switch (widget.style) { case "headline2": return Theme.of(context).textTheme.headline2; @@ -184,7 +184,7 @@ class _TextsState extends State { case "bodyText2": return Theme.of(context).textTheme.bodyText2; case "bodyText_15": - return Theme.of(context).textTheme.bodyText2.copyWith(fontSize: 15.0); + return Theme.of(context).textTheme.bodyText2!.copyWith(fontSize: 15.0); case "bodyText1": return Theme.of(context).textTheme.bodyText1; case "caption": @@ -209,37 +209,37 @@ class _TextsState extends State { ? text : (text.substring( 0, - text.length > widget.maxLength + text.length > widget.maxLength! ? widget.maxLength : text.length)), textAlign: widget.textAlign, overflow: widget.maxLines != null - ? ((widget.maxLines > 1) + ? ((widget.maxLines! > 1) ? TextOverflow.fade : TextOverflow.ellipsis) : null, maxLines: widget.maxLines ?? null, style: widget.style != null - ? _getFontStyle().copyWith( - fontStyle: widget.italic ? FontStyle.italic : null, + ? _getFontStyle()!.copyWith( + fontStyle: widget.italic! ? FontStyle.italic : null, color: widget.color != null ? widget.color - : Theme.of(context).textTheme.bodyText1.color, + : Theme.of(context).textTheme.bodyText1!.color, fontWeight: widget.fontWeight ?? _getFontWeight(), ) : TextStyle( height: widget.heightFactor, decoration: widget.decoration, - fontStyle: widget.italic ? FontStyle.italic : null, + fontStyle: widget.italic! ? FontStyle.italic : null, color: widget.color ?? - Theme.of(context).textTheme.bodyText1.color, + Theme.of(context).textTheme.bodyText1!.color, fontSize: widget.fontSize ?? _getFontSize(), letterSpacing: widget.variant == "overline" ? 1 : null, fontWeight: widget.fontWeight ?? _getFontWeight(), fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins'), ), - if (widget.readMore && text.length > widget.maxLength && hidden) + if (widget.readMore! && text.length > widget.maxLength! && hidden) Positioned( bottom: 0, left: 0, @@ -256,9 +256,9 @@ class _TextsState extends State { ) ], ), - if (widget.allowExpand && - widget.readMore && - text.length > widget.maxLength) + if (widget.allowExpand! && + widget.readMore! && + text.length > widget.maxLength!) Padding( padding: EdgeInsets.only(top: 8.0, right: 8.0, bottom: 8.0), child: InkWell( @@ -269,7 +269,7 @@ class _TextsState extends State { }, child: Text( hidden ? "Read More" : "Read less", - style: _getFontStyle().copyWith( + style: _getFontStyle()!.copyWith( color: Theme.of(context).primaryColor, fontWeight: FontWeight.w800, fontFamily: projectViewModel.isArabic ? 'Poppins' : 'Poppins', diff --git a/lib/widgets/dialogs/ConfirmWithMessageDialog.dart b/lib/widgets/dialogs/ConfirmWithMessageDialog.dart index 1d423458..a39a7893 100644 --- a/lib/widgets/dialogs/ConfirmWithMessageDialog.dart +++ b/lib/widgets/dialogs/ConfirmWithMessageDialog.dart @@ -7,12 +7,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class ConfirmWithMessageDialog extends StatelessWidget { - final String title; - final String message; - final String okTitle; - final VoidCallback onTap; + final String? title; + final String? message; + final String? okTitle; + final VoidCallback? onTap; - const ConfirmWithMessageDialog({Key key, this.title, @required this.message, this.okTitle, this.onTap}) : super(key: key); + const ConfirmWithMessageDialog({Key? key, this.title, @required this.message, this.okTitle, this.onTap}) : super(key: key); @override Widget build(BuildContext context) { @@ -50,7 +50,7 @@ class ConfirmWithMessageDialog extends StatelessWidget { ], ), Text( - message, + message!, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff808080), letterSpacing: -0.48), ), SizedBox(height: 28), @@ -71,7 +71,7 @@ class ConfirmWithMessageDialog extends StatelessWidget { okTitle ?? TranslationBase.of(context).ok, () { Navigator.pop(context); - onTap(); + onTap!(); }, textColor: Colors.white, color: CustomColors.green, diff --git a/lib/widgets/dialogs/alert_dialog.dart b/lib/widgets/dialogs/alert_dialog.dart index 8515e466..52afa0a4 100644 --- a/lib/widgets/dialogs/alert_dialog.dart +++ b/lib/widgets/dialogs/alert_dialog.dart @@ -11,11 +11,11 @@ class AlertDialogBox { final Function okFunction; AlertDialogBox( - {@required this.context, + {required this.context, this.title, @required this.confirmMessage, @required this.okText, - @required this.okFunction}); + required this.okFunction}); showAlertDialog(BuildContext context) { Widget continueButton = diff --git a/lib/widgets/dialogs/confirm_dialog.dart b/lib/widgets/dialogs/confirm_dialog.dart index 4892d09f..ddad9084 100644 --- a/lib/widgets/dialogs/confirm_dialog.dart +++ b/lib/widgets/dialogs/confirm_dialog.dart @@ -6,17 +6,17 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class ConfirmDialog { - final BuildContext context; + final BuildContext? context; final title; final confirmMessage; final okText; final cancelText; - final Function okFunction; - final Function cancelFunction; + final VoidCallback okFunction; + final Function? cancelFunction; final isDissmissable; - ConfirmDialog({@required this.context, this.title, @required this.confirmMessage, @required this.okText, @required this.cancelText, @required this.okFunction, @required this.cancelFunction, this.isDissmissable = true}); + ConfirmDialog({@required this.context, this.title, @required this.confirmMessage, @required this.okText, @required this.cancelText, required this.okFunction, @required this.cancelFunction, this.isDissmissable = true}); showAlertDialog(BuildContext context) { Dialog alert = Dialog( @@ -28,8 +28,8 @@ class ConfirmDialog { confirmMessage, okText, cancelText, - cancelFunction: cancelFunction, - okFunction: okFunction, + cancelFunction: cancelFunction!, + okFunction: okFunction!, ), ), ); @@ -50,13 +50,13 @@ class ConfirmDialog { } class Mdialog extends StatelessWidget { - String title; - String description; - final Function okFunction; - final Function cancelFunction; + String? title; + String? description; + final VoidCallback? okFunction; + final Function? cancelFunction; final okText; final cancelText; - BuildContext _context; + BuildContext? _context; Mdialog(this._context, this.title, this.description, this.okText, this.cancelText, {this.okFunction, this.cancelFunction}); @@ -72,7 +72,7 @@ class Mdialog extends StatelessWidget { children: [ Text( // title != null ? title : TranslationBase.of(context).confirm, - title, + title!, style: TextStyle( fontSize: 24, letterSpacing: -0.94, @@ -81,7 +81,7 @@ class Mdialog extends StatelessWidget { ), Text( // this.confirmMessage, - description, + description!, style: TextStyle( fontSize: 12, letterSpacing: -0.48, @@ -95,8 +95,8 @@ class Mdialog extends StatelessWidget { Expanded( child: InkWell( onTap: () { - Navigator.of(_context).pop(); - cancelFunction(); + Navigator.of(_context!).pop(); + cancelFunction!(); }, child: Container( decoration: containerRadius(CustomColors.lightGreyColor, 12), diff --git a/lib/widgets/dialogs/confirm_send_email_dialog.dart b/lib/widgets/dialogs/confirm_send_email_dialog.dart index e3952225..6d056206 100644 --- a/lib/widgets/dialogs/confirm_send_email_dialog.dart +++ b/lib/widgets/dialogs/confirm_send_email_dialog.dart @@ -7,8 +7,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class ConfirmSendEmailDialog extends StatefulWidget { - final String email; - final GestureTapCallback onTapSendEmail; + final String? email; + final GestureTapCallback? onTapSendEmail; ConfirmSendEmailDialog({this.email, this.onTapSendEmail}); @@ -68,7 +68,7 @@ class _ConfirmSendEmailDialogState extends State { children: [ Expanded( child: Text( - widget.email, + widget.email!, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), ), ), @@ -112,7 +112,7 @@ class _ConfirmSendEmailDialogState extends State { TranslationBase.of(context).send, () { Navigator.pop(context); - widget.onTapSendEmail(); + widget.onTapSendEmail!(); }, color: Color(0xff359846), ), diff --git a/lib/widgets/dialogs/covid_consent_dialog.dart b/lib/widgets/dialogs/covid_consent_dialog.dart index d846c9e1..f8100036 100644 --- a/lib/widgets/dialogs/covid_consent_dialog.dart +++ b/lib/widgets/dialogs/covid_consent_dialog.dart @@ -4,12 +4,12 @@ import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:flutter/material.dart'; class CovidConsentDialog extends StatelessWidget { - final String title; - final String message; - final String okTitle; - final VoidCallback onTap; + final String? title; + final String? message; + final String? okTitle; + final VoidCallback? onTap; - const CovidConsentDialog({Key key, this.title, @required this.message, this.okTitle, this.onTap}) : super(key: key); + const CovidConsentDialog({Key? key, this.title, @required this.message, this.okTitle, this.onTap}) : super(key: key); @override Widget build(BuildContext context) { @@ -47,7 +47,7 @@ class CovidConsentDialog extends StatelessWidget { ], ), Text( - message, + message!, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff808080), letterSpacing: -0.48), ), SizedBox(height: 28), @@ -68,7 +68,7 @@ class CovidConsentDialog extends StatelessWidget { okTitle ?? TranslationBase.of(context).ok, () { Navigator.pop(context); - onTap(); + onTap!(); }, textColor: Colors.white, color: CustomColors.green, diff --git a/lib/widgets/dialogs/radio-group-dialog.dart b/lib/widgets/dialogs/radio-group-dialog.dart index 7b4c3750..0a1d1036 100644 --- a/lib/widgets/dialogs/radio-group-dialog.dart +++ b/lib/widgets/dialogs/radio-group-dialog.dart @@ -5,14 +5,14 @@ import 'package:flutter/material.dart'; class RadioGroupDialog extends StatefulWidget { - final BuildContext context; + final BuildContext? context; final title; - final List list; + final List? list; final okText; final cancelText; - final Function(IdNamePair) okFunction; - final Function cancelFunction; - IdNamePair selectedValue; + final Function(IdNamePair)? okFunction; + final Function? cancelFunction; + IdNamePair? selectedValue; RadioGroupDialog( {@required this.context, @@ -33,7 +33,7 @@ class RadioGroupState extends State { @override void initState() { super.initState(); - widget.selectedValue = widget.selectedValue ?? widget.list[0]; + widget.selectedValue = widget.selectedValue ?? widget.list![0]; } @override @@ -50,7 +50,7 @@ class RadioGroupState extends State { }); Widget continueButton = TextButton(child: Text(this.widget.okText), onPressed: () { - this.widget.okFunction(widget.selectedValue); + this.widget.okFunction!(widget.selectedValue!); Navigator.of(context).pop(); }); @@ -79,9 +79,9 @@ class RadioGroupState extends State { Container( child: Column( children: - widget.list.map((data) => RadioListTile( + widget.list!.map((data) => RadioListTile( title: Text("${data.name}"), - groupValue: widget.selectedValue.id, + groupValue: widget.selectedValue!.id, value: data.id, onChanged: (val) { setState(() { diff --git a/lib/widgets/dialogs/radio_selection_dialog.dart b/lib/widgets/dialogs/radio_selection_dialog.dart index dc460009..934b18f0 100644 --- a/lib/widgets/dialogs/radio_selection_dialog.dart +++ b/lib/widgets/dialogs/radio_selection_dialog.dart @@ -10,20 +10,20 @@ class RadioSelectionDialogModel { } class RadioSelectionDialog extends StatefulWidget { - final Function(int) onValueSelected; - final List listData; - final int selectedIndex; - final bool isScrollable; - final bool isShowSearch; + final Function(int)? onValueSelected; + final List? listData; + final int? selectedIndex; + final bool? isScrollable; + final bool? isShowSearch; - const RadioSelectionDialog({Key key, this.onValueSelected, this.listData, this.selectedIndex, this.isScrollable = false, this.isShowSearch = false}) : super(key: key); + const RadioSelectionDialog({Key? key, this.onValueSelected, this.listData, this.selectedIndex, this.isScrollable = false, this.isShowSearch = false}) : super(key: key); @override State createState() => new RadioSelectionDialogState(); } class RadioSelectionDialogState extends State { - int selectedIndex; + late int selectedIndex; List tempListData = []; TextEditingController controller = new TextEditingController(); @@ -37,8 +37,8 @@ class RadioSelectionDialogState extends State { addAllData() { tempListData.clear(); - for (int i = 0; i < widget.listData.length; i++) { - tempListData.add(widget.listData[i]); + for (int i = 0; i < widget.listData!.length; i++) { + tempListData.add(widget.listData![i]); } setState(() {}); } @@ -83,7 +83,7 @@ class RadioSelectionDialogState extends State { TranslationBase.of(context).pleaseSelectFromBelowOptions, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56), ), - widget.isShowSearch + widget.isShowSearch! ? Padding( padding: const EdgeInsets.all(8.0), child: TextField( @@ -91,9 +91,9 @@ class RadioSelectionDialogState extends State { onChanged: (v) { if (v.length > 0) { tempListData.clear(); - for (int i = 0; i < widget.listData.length; i++) { - if (widget.listData[i].title.toLowerCase().contains(v.toLowerCase())) { - tempListData.add(widget.listData[i]); + for (int i = 0; i < widget.listData!.length; i++) { + if (widget.listData![i].title.toLowerCase().contains(v.toLowerCase())) { + tempListData.add(widget.listData![i]); } } } else { @@ -111,14 +111,14 @@ class RadioSelectionDialogState extends State { ), ) : Container(), - SizedBox(height: widget.isScrollable ? 12 : 0), + SizedBox(height: widget.isScrollable! ? 12 : 0), SizedBox( - height: widget.isScrollable ? MediaQuery.of(context).size.height * .4 : null, + height: widget.isScrollable! ? MediaQuery.of(context).size.height * .4 : null, child: ListView.separated( - physics: widget.isScrollable ? BouncingScrollPhysics() : NeverScrollableScrollPhysics(), + physics: widget.isScrollable! ? BouncingScrollPhysics() : NeverScrollableScrollPhysics(), // shrinkWrap: !widget.isScrollable, - shrinkWrap: !widget.isScrollable, - padding: EdgeInsets.only(bottom: widget.isScrollable ? 21 : 42, top: 10), + shrinkWrap: !widget.isScrollable!, + padding: EdgeInsets.only(bottom: widget.isScrollable! ? 21 : 42, top: 10), itemBuilder: (context, index) { return InkWell( onTap: () { @@ -137,7 +137,7 @@ class RadioSelectionDialogState extends State { groupValue: selectedIndex, onChanged: (value) { setState(() { - selectedIndex = value; + selectedIndex = value!; }); }, ), @@ -157,7 +157,7 @@ class RadioSelectionDialogState extends State { separatorBuilder: (context, index) => SizedBox(height: 10), itemCount: tempListData.length), ), - SizedBox(height: widget.isScrollable ? 12 : 0), + SizedBox(height: widget.isScrollable! ? 12 : 0), Row( mainAxisSize: MainAxisSize.min, children: [ @@ -166,7 +166,7 @@ class RadioSelectionDialogState extends State { TranslationBase.of(context).save, () { Navigator.pop(context); - widget.onValueSelected(selectedIndex); + widget.onValueSelected!(selectedIndex); }, color: Color(0xff349745), ), diff --git a/lib/widgets/dialogs/select_location_dialog.dart b/lib/widgets/dialogs/select_location_dialog.dart index cdf53454..4ae3554a 100644 --- a/lib/widgets/dialogs/select_location_dialog.dart +++ b/lib/widgets/dialogs/select_location_dialog.dart @@ -5,11 +5,11 @@ import 'package:flutter/material.dart'; // ignore: must_be_immutable class SelectLocationDialog extends StatefulWidget { - final List addresses; - final Function(AddressInfo) onValueSelected; - AddressInfo selectedAddress; + final List? addresses; + final Function(AddressInfo)? onValueSelected; + AddressInfo? selectedAddress; - SelectLocationDialog({Key key, this.addresses, this.onValueSelected, this.selectedAddress}); + SelectLocationDialog({Key? key, this.addresses, this.onValueSelected, this.selectedAddress}); @override _SelectLocationDialogState createState() => _SelectLocationDialogState(); @@ -19,9 +19,9 @@ class _SelectLocationDialogState extends State { @override void initState() { super.initState(); - widget.selectedAddress = widget.selectedAddress ?? widget.addresses[0]; - for(int i=0;i { children: [ Divider(), ...List.generate( - widget.addresses.length, + widget.addresses!.length, (index) => Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -60,19 +60,19 @@ class _SelectLocationDialogState extends State { child: InkWell( onTap: () { setState(() { - widget.selectedAddress = widget.addresses[index]; + widget.selectedAddress = widget.addresses![index]; }); }, child: ListTile( title: Text( - widget.addresses[index].address1, + widget.addresses![index].address1, style: TextStyle( fontWeight: FontWeight.w600, letterSpacing: -0.46, ), ), leading: Radio( - value: widget.addresses[index], + value: widget.addresses![index], groupValue: widget.selectedAddress, activeColor: Colors.red[800], onChanged: (value) { @@ -135,7 +135,7 @@ class _SelectLocationDialogState extends State { flex: 1, child: InkWell( onTap: () { - widget.onValueSelected(widget.selectedAddress); + widget.onValueSelected!(widget.selectedAddress!); Navigator.pop(context); }, child: Padding( diff --git a/lib/widgets/dialogs/selection-dailog.dart b/lib/widgets/dialogs/selection-dailog.dart index f3dfe083..3daf0009 100644 --- a/lib/widgets/dialogs/selection-dailog.dart +++ b/lib/widgets/dialogs/selection-dailog.dart @@ -7,13 +7,13 @@ class SelectionDialog extends StatefulWidget{ final List items; BuildContext context; - SelectionDialog(this.context,{@required this.title, @required this.items}); + SelectionDialog(this.context,{required this.title, required this.items}); @override State createState() => SelectionDialogState(); - Future show() async{ + Future> show() async{ return showDialog(context: context, builder: (ctx){ return this; }); diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index e71a4266..6f27d6da 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -72,19 +72,19 @@ class _AppDrawerState extends State { checkUserData(); } - ProjectViewModel projectProvider; + ProjectViewModel? projectProvider; var sharedPref = new AppSharedPreferences(); var familyFileProvider = FamilyFilesProvider(); PharmacyModuleViewModel pharmacyModuleViewModel = locator(); - AuthenticatedUser user; - AuthenticatedUser mainUser; + AuthenticatedUser? user; + AuthenticatedUser? mainUser; AuthenticatedUserObject authenticatedUserObject = locator(); VitalSignService _vitalSignService = locator(); AppointmentRateViewModel appointmentRateViewModel = locator(); PrivilegeService _privilegeService = locator(); - ToDoCountProviderModel toDoProvider; - String booldType; - String notificationCount; + ToDoCountProviderModel? toDoProvider; + String? booldType; + String? notificationCount; final authService = new AuthProvider(); String pharmacyLiveCareQRCode = ""; @@ -142,12 +142,12 @@ class _AppDrawerState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - (user != null && projectProvider.isLogin) ? user.firstName + ' ' + user.lastName : TranslationBase.of(context).cantSeeProfile, + (user != null && projectProvider!.isLogin) ? user!.firstName + ' ' + user!.lastName : TranslationBase.of(context).cantSeeProfile, style: TextStyle(color: Color(0xff2E303A), fontWeight: FontWeight.bold, fontSize: 20, letterSpacing: -1.2, height: 35 / 20), ), Text( - (user != null && projectProvider.isLogin) - ? TranslationBase.of(context).fileNumber + ": " + user.patientID.toString() + (user != null && projectProvider!.isLogin) + ? TranslationBase.of(context).fileNumber + ": " + user!.patientID.toString() : TranslationBase.of(context).loginRegisterNow, style: TextStyle( color: Color(0xff2E303A), @@ -168,7 +168,7 @@ class _AppDrawerState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - (user != null && projectProvider.isLogin) + (user != null && projectProvider!.isLogin) ? Container() : InkWell( child: DrawerItem( @@ -179,30 +179,30 @@ class _AppDrawerState extends State { projectProvider: projectProvider, ), onTap: () { - sharedPref.setBool(IS_ROBOT_INIT, null); + sharedPref.setBool(IS_ROBOT_INIT, false); sharedPref.remove(CLINICS_LIST); - if (projectProvider.isArabic) { - projectProvider.changeLanguage('en'); + if (projectProvider!.isArabic) { + projectProvider!.changeLanguage('en'); locator().hamburgerMenu.logMenuItemClick('change language to english'); } else { - projectProvider.changeLanguage('ar'); + projectProvider!.changeLanguage('ar'); locator().hamburgerMenu.logMenuItemClick('change language to arabic'); } var themeNotifier = Provider.of(context, listen: false); - themeNotifier.setTheme(defaultTheme(fontName: projectProvider.isArabic ? 'Cairo' : 'Poppins')); + themeNotifier.setTheme(defaultTheme(fontName: projectProvider!.isArabic ? 'Cairo' : 'Poppins')); }, ), - (user != null && projectProvider.isLogin) + (user != null && projectProvider!.isLogin) ? Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - (user.isFamily == null || user.isFamily == false) + (user!.isFamily == null || user!.isFamily == false) ? InkWell( child: DrawerItem(TranslationBase.of(context).family, SvgPicture.asset("assets/images/new/family_files.svg"), isImageIcon: true, bottomLine: false, - textColor: Theme.of(context).textTheme.bodyText1.color, - iconColor: Theme.of(context).textTheme.bodyText1.color, + textColor: Theme.of(context).textTheme.bodyText1!.color, + iconColor: Theme.of(context).textTheme.bodyText1!.color, sideArrow: true, letterSpacing: -0.84, projectProvider: projectProvider), @@ -224,12 +224,12 @@ class _AppDrawerState extends State { return Padding(padding: EdgeInsets.all(10), child: Text('')); default: if (snapshot.hasError) - return Padding(padding: EdgeInsets.all(10), child: Text(snapshot.error)); + return Padding(padding: EdgeInsets.all(10), child: Text(snapshot.error.toString())); else return Container( child: Column( children: [ - user.isFamily == true + user!.isFamily == true ? Container( padding: EdgeInsets.only(bottom: 5, left: 4), child: InkWell( @@ -248,14 +248,14 @@ class _AppDrawerState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( - mainUser.firstName + ' ' + mainUser.lastName, + mainUser!.firstName + ' ' + mainUser!.lastName, color: Color(0xff2E303A), //Theme.of(context).textTheme.bodyText1.color, fontWeight: FontWeight.w600, fontSize: 12, letterSpacing: -0.33, ), AppText( - TranslationBase.of(context).fileno + ": " + mainUser.patientID.toString(), + TranslationBase.of(context).fileno + ": " + mainUser!.patientID.toString(), color: Color(0xff989898), fontSize: 12, letterSpacing: -0.33, @@ -276,7 +276,7 @@ class _AppDrawerState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, - children: snapshot.data.getAllSharedRecordsByStatusList.map((result) { + children: snapshot.data!.getAllSharedRecordsByStatusList.map((result) { return result.status == 3 ? Container( padding: EdgeInsets.only(bottom: 5), @@ -288,7 +288,7 @@ class _AppDrawerState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: Icon(Icons.person, color: result.responseID == user.patientID ? Colors.transparent : Colors.transparent), + child: Icon(Icons.person, color: result.responseID == user!.patientID ? Colors.transparent : Colors.transparent), ), Expanded( flex: 7, @@ -299,14 +299,14 @@ class _AppDrawerState extends State { children: [ AppText( result.patientName, - color: result.responseID == user.patientID ? Color(0xffC5272D) : Color(0xff2B353E), + color: result.responseID == user!.patientID ? Color(0xffC5272D) : Color(0xff2B353E), fontWeight: FontWeight.w600, fontSize: 11, letterSpacing: -0.33, ), AppText( TranslationBase.of(context).fileno + ": " + result.responseID.toString(), - color: result.responseID == user.patientID ? Color(0xffC5272D) : Color(0xff989898), + color: result.responseID == user!.patientID ? Color(0xffC5272D) : Color(0xff989898), fontSize: 11, letterSpacing: -0.33, ), @@ -331,17 +331,17 @@ class _AppDrawerState extends State { mHeight(20), InkWell( child: DrawerItem(TranslationBase.of(context).arabicChange, - Padding(child: Image.asset('assets/images/lang.png'), padding: EdgeInsets.only(left: 3, right: 3, top: 3, bottom: projectProvider.isArabic ? 3 : 0)), - isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, fontHeight: projectProvider.isArabic ? 1 : 0.8, projectProvider: projectProvider), + Padding(child: Image.asset('assets/images/lang.png'), padding: EdgeInsets.only(left: 3, right: 3, top: 3, bottom: projectProvider!.isArabic ? 3 : 0)), + isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, fontHeight: projectProvider!.isArabic ? 1 : 0.8, projectProvider: projectProvider), onTap: () { sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); sharedPref.remove(CLINICS_LIST); - sharedPref.setBool(IS_ROBOT_INIT, null); - if (projectProvider.isArabic) { - projectProvider.changeLanguage('en'); + sharedPref.setBool(IS_ROBOT_INIT, false); + if (projectProvider!.isArabic) { + projectProvider!.changeLanguage('en'); locator().hamburgerMenu.logMenuItemClick('change language to english'); } else { - projectProvider.changeLanguage('ar'); + projectProvider!.changeLanguage('ar'); locator().hamburgerMenu.logMenuItemClick('change language to arabic'); } }, @@ -370,7 +370,7 @@ class _AppDrawerState extends State { letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider, - count: toDoProvider.notificationsCount != "0" && !projectProvider.isLoginChild + count: toDoProvider!.notificationsCount != "0" && !projectProvider!.isLoginChild ? new Container( padding: EdgeInsets.all(4), margin: EdgeInsets.all(2), @@ -383,10 +383,10 @@ class _AppDrawerState extends State { minHeight: 20, ), child: new Text( - toDoProvider.notificationsCount.toString(), + toDoProvider!.notificationsCount.toString(), style: new TextStyle( color: Colors.white, - fontSize: projectProvider.isArabic ? 8 : 9, + fontSize: projectProvider!.isArabic ? 8 : 9, ), textAlign: TextAlign.center, ), @@ -399,11 +399,11 @@ class _AppDrawerState extends State { onTap: () { //NotificationsPage // Navigator.of(context).pop(); - if (!projectProvider.isLoginChild) Navigator.push(context, FadePage(page: NotificationsPage())); + if (!projectProvider!.isLoginChild) Navigator.push(context, FadePage(page: NotificationsPage())); locator().hamburgerMenu.logMenuItemClick('notifications'); }, ), - if (projectProvider.havePrivilege(3)) + if (projectProvider!.havePrivilege(3)) InkWell( child: DrawerItem(TranslationBase.of(context).appsetting, SvgPicture.asset("assets/images/new/app_setting.svg"), isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), @@ -445,7 +445,7 @@ class _AppDrawerState extends State { InkWell( child: DrawerItem(TranslationBase.of(context).privacyPolicy, Icons.web, letterSpacing: -0.84, fontSize: 14, bottomLine: false), onTap: () { - if (projectProvider.isArabic) + if (projectProvider!.isArabic) launch("https://hmg.com/ar/Pages/Privacy.aspx"); else launch("https://hmg.com/en/Pages/Privacy.aspx"); @@ -546,7 +546,7 @@ class _AppDrawerState extends State { } readQRCode() async { - pharmacyLiveCareQRCode = (await BarcodeScanner.scan())?.rawContent; + pharmacyLiveCareQRCode = (await BarcodeScanner.scan()).rawContent; print(pharmacyLiveCareQRCode); GifLoaderDialogUtils.showMyDialog(context); LiveCareService service = new LiveCareService(); @@ -597,12 +597,12 @@ class _AppDrawerState extends State { cancelText: TranslationBase.of(context).cancel_nocaps, okFunction: () async { authenticatedUserObject.logout(); - projectProvider.isLogin = false; + projectProvider!.isLogin = false; await authenticatedUserObject.getUser(); _vitalSignService.heightCm = ""; _vitalSignService.weightKg = ""; await _privilegeService.getPrivilege(); - projectProvider.setPrivilegeModelList(privilege: _privilegeService.privilegeModelList); + projectProvider!.setPrivilegeModelList(privilege: _privilegeService.privilegeModelList); var appLanguage = await sharedPref.getString(APP_LANGUAGE); await sharedPref.clear(); await sharedPref.setString(APP_LANGUAGE, appLanguage); @@ -653,6 +653,7 @@ class _AppDrawerState extends State { return familyFileProvider.getSharedRecordByStatus(); } } + return familyFileProvider.getSharedRecordByStatus(); } switchUser(user, context) { @@ -747,12 +748,12 @@ class _AppDrawerState extends State { } getToDoCount() { - toDoProvider.setState(0, true, toDoProvider.notificationsCount); + toDoProvider!.setState(0, true, toDoProvider!.notificationsCount); ClinicListService service = new ClinicListService(); service.getActiveAppointmentNo(context).then((res) { print(res['AppointmentActiveNumber']); if (res['MessageStatus'] == 1 && res['AppointmentActiveNumber'] != null) { - toDoProvider.setState(res['AppointmentActiveNumber'], true, toDoProvider.notificationsCount); + toDoProvider!.setState(res['AppointmentActiveNumber'], true, toDoProvider!.notificationsCount); } else {} }).catchError((err) { print(err); diff --git a/lib/widgets/drawer/drawer_item_widget.dart b/lib/widgets/drawer/drawer_item_widget.dart index df8e6062..5920954d 100644 --- a/lib/widgets/drawer/drawer_item_widget.dart +++ b/lib/widgets/drawer/drawer_item_widget.dart @@ -7,19 +7,19 @@ import 'package:flutter/material.dart'; /// class DrawerItem extends StatefulWidget { - final String title; - final String subTitle; + final String? title; + final String? subTitle; final icon; - final Color textColor; - final Color iconColor; - final bool bottomLine; - final bool sideArrow; - final Widget count; - final bool isImageIcon; - final double fontHeight; - final double letterSpacing; - final double fontSize; - final ProjectViewModel projectProvider; + final Color? textColor; + final Color? iconColor; + final bool? bottomLine; + final bool? sideArrow; + final Widget? count; + final bool? isImageIcon; + final double? fontHeight; + final double? letterSpacing; + final double? fontSize; + final ProjectViewModel? projectProvider; DrawerItem(this.title, this.icon, {this.fontSize, this.letterSpacing, this.textColor, this.iconColor, this.subTitle = '', this.bottomLine = true, this.count, this.sideArrow = false, this.isImageIcon = false, this.fontHeight, this.projectProvider}); @@ -37,7 +37,7 @@ class _DrawerItemState extends State { border: Border( bottom: BorderSide( // <--- left side - color: Colors.grey[200], + color: Colors.grey[200]!, width: 1.0, ), )) @@ -52,7 +52,7 @@ class _DrawerItemState extends State { ? widget.icon : Icon( widget.icon, - color: widget.iconColor == null ? Theme.of(context).textTheme.bodyText1.color : widget.iconColor, + color: widget.iconColor == null ? Theme.of(context).textTheme.bodyText1?.color : widget.iconColor, size: SizeConfig.imageSizeMultiplier * 5, )), Expanded( @@ -61,7 +61,7 @@ class _DrawerItemState extends State { Row( children: [ AppText( - widget.title, + widget.title!, fontWeight: FontWeight.w600, fontSize: widget.fontSize, height: widget.fontHeight, @@ -72,12 +72,12 @@ class _DrawerItemState extends State { ), widget.subTitle != '' ? AppText( - widget.subTitle, + widget.subTitle!, fontSize: SizeConfig.textMultiplier * 2.5, ) : SizedBox(), ])), - widget.sideArrow == true ? Expanded(flex: 1, child: Icon(widget.projectProvider.isArabic ? Icons.keyboard_arrow_left : Icons.keyboard_arrow_right, color: Colors.black)) : Expanded(flex: 1, child: SizedBox()), + widget.sideArrow == true ? Expanded(flex: 1, child: Icon(widget.projectProvider!.isArabic ? Icons.keyboard_arrow_left : Icons.keyboard_arrow_right, color: Colors.black)) : Expanded(flex: 1, child: SizedBox()), ], ), )); diff --git a/lib/widgets/errors/app_embedded_error.dart b/lib/widgets/errors/app_embedded_error.dart index b8bcc0cc..b2355a01 100644 --- a/lib/widgets/errors/app_embedded_error.dart +++ b/lib/widgets/errors/app_embedded_error.dart @@ -6,8 +6,8 @@ import 'package:flutter/material.dart'; /// [error] the message we show to the user class AppEmbeddedError extends StatelessWidget { const AppEmbeddedError({ - Key key, - @required this.error, + required Key key, + required this.error, }) : super(key: key); final String error; diff --git a/lib/widgets/habib_logo_widget.dart b/lib/widgets/habib_logo_widget.dart index 3993d952..84aaa076 100644 --- a/lib/widgets/habib_logo_widget.dart +++ b/lib/widgets/habib_logo_widget.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; class HabibLogoWidget extends StatelessWidget { - HabibLogoWidget({Key key}) : super(key: key); + HabibLogoWidget({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Row( diff --git a/lib/widgets/hospital_location.dart b/lib/widgets/hospital_location.dart index 056aa218..298779de 100644 --- a/lib/widgets/hospital_location.dart +++ b/lib/widgets/hospital_location.dart @@ -14,7 +14,7 @@ class HospitalLocation extends StatelessWidget { final bool showCity; final String waitingTime; - HospitalLocation(this.location, {Key key, this.showCity = false, this.waitingTime}) : super(key: key); + HospitalLocation(this.location, {Key? key, this.showCity = false, required this.waitingTime}) : super(key: key); @override Widget build(BuildContext context) { @@ -60,7 +60,7 @@ class HospitalLocation extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (showCity) MyRichText(TranslationBase.of(context).city + ":", location.cityName?.trim().toString(), projectViewModel.isArabic), + if (showCity) MyRichText(TranslationBase.of(context).city + ":", location.cityName!.trim().toString(), projectViewModel.isArabic), MyRichText(TranslationBase.of(context).distance + ":", location.distanceInKilometers.toString() + " " + TranslationBase.of(context).km_ ?? "", projectViewModel.isArabic), if (waitingTime != null) MyRichText(TranslationBase.of(context).waitingTime, waitingTime, projectViewModel.isArabic), ], diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index f38ad57c..67fe894e 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -30,14 +30,14 @@ var _InAppBrowserOptions = InAppBrowserClassOptions( ios: IOSInAppBrowserOptions(hideToolbarBottom: true, toolbarBottomBackgroundColor: Colors.white, closeButtonColor: Colors.white, presentationStyle: IOSUIModalPresentationStyle.OVER_FULL_SCREEN)); class MyInAppBrowser extends InAppBrowser { - _PAYMENT_TYPE paymentType; + _PAYMENT_TYPE? paymentType; // static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT - // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT - static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE + // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE // static String SERVICE_URL = 'https://uat.hmgwebservices.com/payfortforvidaplus/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL UAT VIDA PLUS @@ -55,18 +55,18 @@ class MyInAppBrowser extends InAppBrowser { static List errorURLS = ['PayfortCancel', 'errorpage', 'Failed', 'orderdetails', 'redirectToApplePay', 'mdlaboratories.com/?', 'cancel', 'canceled']; - final Function onExitCallback; - final Function onLoadStartCallback; - final BuildContext context; + final Function? onExitCallback; + final Function? onLoadStartCallback; + final BuildContext? context; AppSharedPreferences sharedPref = AppSharedPreferences(); AuthProvider authProvider = new AuthProvider(); InAppBrowser browser = new InAppBrowser(); // AuthenticatedUser authUser; - AppoitmentAllHistoryResultList appo; + late AppoitmentAllHistoryResultList? appo; - String deviceToken; + String deviceToken = ""; double lat = 0.0; double long = 0.0; @@ -80,17 +80,19 @@ class MyInAppBrowser extends InAppBrowser { } @override - Future onLoadStart(Uri url) async { - if (onLoadStartCallback != null) onLoadStartCallback(url.toString()); + Future onLoadStart(Uri? url) async { + if (onLoadStartCallback != null) onLoadStartCallback!(url.toString()); } + + @override - Future onLoadStop(Uri url) async { + Future onLoadStop(Uri? url) async { print("\n\nStopped $url\n\n"); } @override - void onLoadError(Uri url, int code, String message) { + void onLoadError(Uri? url, int code, String message) { print("Can't load $url.. Error: $message"); } @@ -100,7 +102,7 @@ class MyInAppBrowser extends InAppBrowser { @override void onExit() { print("\n\nBrowser closed!\n\n"); - if (onExitCallback != null) onExitCallback(appo, isPaymentDone); + if (onExitCallback != null) onExitCallback!(appo, isPaymentDone); } @override @@ -125,7 +127,7 @@ class MyInAppBrowser extends InAppBrowser { this.deviceToken = deviceToken; } - openPackagesPaymentBrowser({@required int customer_id, @required int order_id}) { + openPackagesPaymentBrowser({required int customer_id, required int order_id}) { paymentType = _PAYMENT_TYPE.PACKAGES; var full_url = '$PACKAGES_REQUEST_PAYMENT_URL?customer_id=$customer_id&order_id=$order_id'; this.openUrlRequest(urlRequest: URLRequest(url: Uri.parse(full_url)), options: _InAppBrowserOptions); @@ -138,7 +140,7 @@ class MyInAppBrowser extends InAppBrowser { // await getPatientData(); if (paymentMethod == "ApplePay") { getDeviceToken(); - MyChromeSafariBrowser safariBrowser = new MyChromeSafariBrowser(new MyInAppBrowser(), onExitCallback: browser.onExit, onLoadStartCallback: this.browser.onLoadStart, appo: this.appo); + MyChromeSafariBrowser safariBrowser = new MyChromeSafariBrowser(new MyInAppBrowser(), onExitCallback: browser.onExit, onLoadStartCallback: this.browser.onLoadStart, appo: this.appo!); if (context != null) GifLoaderDialogUtils.showMyDialog(context); @@ -242,7 +244,7 @@ class MyInAppBrowser extends InAppBrowser { openPharmacyPaymentBrowser(OrderDetailModel order, double amount, String orderDesc, String transactionID, String emailId, String paymentMethod, String patientName, dynamic patientID, AuthenticatedUser authenticatedUser, InAppBrowser browser) { this.browser = browser; - MyChromeSafariBrowser safariBrowser = new MyChromeSafariBrowser(new MyInAppBrowser(), onExitCallback: browser.onExit, onLoadStartCallback: this.browser.onLoadStart, appo: this.appo); + MyChromeSafariBrowser safariBrowser = new MyChromeSafariBrowser(new MyInAppBrowser(), onExitCallback: browser.onExit, onLoadStartCallback: this.browser.onLoadStart, appo: this.appo!); // getPatientData(); generatePharmacyURL(order, amount, orderDesc, transactionID, emailId, paymentMethod, patientName, patientID, authenticatedUser).then((value) { if (order.customValuesXml.contains("ApplePay")) { @@ -469,7 +471,7 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser { final Function onLoadStartCallback; AppoitmentAllHistoryResultList appo; - MyChromeSafariBrowser(browserFallback, {@required this.onExitCallback, @required this.onLoadStartCallback, @required this.appo}); + MyChromeSafariBrowser(browserFallback, {required this.onExitCallback, required this.onLoadStartCallback, required this.appo}); @override void onOpened() { diff --git a/lib/widgets/input/custom_switch.dart b/lib/widgets/input/custom_switch.dart index a43079dc..ddb23eee 100644 --- a/lib/widgets/input/custom_switch.dart +++ b/lib/widgets/input/custom_switch.dart @@ -1,72 +1,72 @@ -import 'package:flutter/animation.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -/// Custom switch widget -/// [value] switch is active or not -/// [onChanged] function to be executed after sometime -/// [activeColor] color of active status -/// [inactiveColor] color of inactive status -class CustomSwitch extends StatefulWidget { - final bool value; - final AsyncCallback onChanged; - final Color activeColor; - final Color inactiveColor; - - CustomSwitch({Key key, this.value, this.onChanged, this.activeColor, this.inactiveColor}) : super(key: key); - - @override - _CustomSwitchState createState() => _CustomSwitchState(); -} - -class _CustomSwitchState extends State with SingleTickerProviderStateMixin { - Animation _circleAnimation; - AnimationController _animationController; - - @override - void initState() { - super.initState(); - _animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 500)); - _circleAnimation = Tween(begin: 0.0, end: 22.0).animate(CurvedAnimation(parent: _animationController, curve: Curves.easeOutQuint, reverseCurve: Curves.easeInQuint)); - if (widget.value) _animationController.forward(); - } - - @override - Widget build(BuildContext context) { - return AnimatedBuilder( - animation: _animationController, - builder: (context, child) { - bool _switchStatus = _circleAnimation.status == AnimationStatus.dismissed || _circleAnimation.status == AnimationStatus.reverse; - return GestureDetector( - onTap: Feedback.wrapForTap(() async { - if (widget.value) { - _animationController.reverse(); - } else { - _animationController.forward(); - } - await widget.onChanged(); - }, context), - child: AnimatedContainer( - duration: Duration(milliseconds: 200), - width: 50.0, - height: 25.0, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.0), color: _switchStatus ? widget.inactiveColor : widget.activeColor), - child: Padding( - padding: EdgeInsets.only(top: 4.0, bottom: 4.0, right: 6.0, left: 6.0), - child: Row( - children: [ - Container(width: _circleAnimation.value), - Container( - width: 16.0, - height: 16.0, - decoration: BoxDecoration(boxShadow: [BoxShadow(color: Colors.grey[800].withOpacity(0.15), offset: Offset(0, 4.0), blurRadius: 5.0)], shape: BoxShape.circle, color: Colors.white), - ) - ], - ), - ), - ), - ); - }, - ); - } -} +// import 'package:flutter/animation.dart'; +// import 'package:flutter/foundation.dart'; +// import 'package:flutter/material.dart'; +// +// /// Custom switch widget +// /// [value] switch is active or not +// /// [onChanged] function to be executed after sometime +// /// [activeColor] color of active status +// /// [inactiveColor] color of inactive status +// class CustomSwitch extends StatefulWidget { +// final bool value; +// final AsyncCallback onChanged; +// final Color activeColor; +// final Color inactiveColor; +// +// CustomSwitch({Key key, this.value, this.onChanged, this.activeColor, this.inactiveColor}) : super(key: key); +// +// @override +// _CustomSwitchState createState() => _CustomSwitchState(); +// } +// +// class _CustomSwitchState extends State with SingleTickerProviderStateMixin { +// Animation _circleAnimation; +// AnimationController _animationController; +// +// @override +// void initState() { +// super.initState(); +// _animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 500)); +// _circleAnimation = Tween(begin: 0.0, end: 22.0).animate(CurvedAnimation(parent: _animationController, curve: Curves.easeOutQuint, reverseCurve: Curves.easeInQuint)); +// if (widget.value) _animationController.forward(); +// } +// +// @override +// Widget build(BuildContext context) { +// return AnimatedBuilder( +// animation: _animationController, +// builder: (context, child) { +// bool _switchStatus = _circleAnimation.status == AnimationStatus.dismissed || _circleAnimation.status == AnimationStatus.reverse; +// return GestureDetector( +// onTap: Feedback.wrapForTap(() async { +// if (widget.value) { +// _animationController.reverse(); +// } else { +// _animationController.forward(); +// } +// await widget.onChanged(); +// }, context), +// child: AnimatedContainer( +// duration: Duration(milliseconds: 200), +// width: 50.0, +// height: 25.0, +// decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.0), color: _switchStatus ? widget.inactiveColor : widget.activeColor), +// child: Padding( +// padding: EdgeInsets.only(top: 4.0, bottom: 4.0, right: 6.0, left: 6.0), +// child: Row( +// children: [ +// Container(width: _circleAnimation.value), +// Container( +// width: 16.0, +// height: 16.0, +// decoration: BoxDecoration(boxShadow: [BoxShadow(color: Colors.grey[800].withOpacity(0.15), offset: Offset(0, 4.0), blurRadius: 5.0)], shape: BoxShape.circle, color: Colors.white), +// ) +// ], +// ), +// ), +// ), +// ); +// }, +// ); +// } +// } diff --git a/lib/widgets/input/date_picker/button_actions.dart b/lib/widgets/input/date_picker/button_actions.dart index 7f10b3c1..04e118b6 100644 --- a/lib/widgets/input/date_picker/button_actions.dart +++ b/lib/widgets/input/date_picker/button_actions.dart @@ -1,26 +1,26 @@ -import 'package:diplomaticquarterapp/widgets/Buttons/button.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -class ButtonActions extends StatelessWidget { - final VoidCallback onPositive; - - const ButtonActions({ - Key key, - @required this.onPositive, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only(bottom: 12.0), - child: FractionallySizedBox( - widthFactor: 0.6, - child: Button( - onTap: onPositive, - label: "Confirm", - ), - ), - ); - } -} +// import 'package:diplomaticquarterapp/widgets/Buttons/button.dart'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter/material.dart'; +// +// class ButtonActions extends StatelessWidget { +// final VoidCallback onPositive; +// +// const ButtonActions({ +// Key key, +// @required this.onPositive, +// }) : super(key: key); +// +// @override +// Widget build(BuildContext context) { +// return Container( +// margin: EdgeInsets.only(bottom: 12.0), +// child: FractionallySizedBox( +// widthFactor: 0.6, +// child: Button( +// onTap: onPositive, +// label: "Confirm", +// ), +// ), +// ); +// } +// } diff --git a/lib/widgets/input/date_picker/date_picker.dart b/lib/widgets/input/date_picker/date_picker.dart index f3e2406c..5ea7dc9d 100644 --- a/lib/widgets/input/date_picker/date_picker.dart +++ b/lib/widgets/input/date_picker/date_picker.dart @@ -1,1459 +1,1459 @@ -import 'dart:async'; -import 'dart:math' as math; - -import 'package:flutter/gestures.dart' show DragStartBehavior; -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; - -import 'button_actions.dart'; -import 'era_mode.dart'; - -/// Initial display mode of the date picker dialog. -/// -/// Date picker UI mode for either showing a list of available years or a -/// monthly calendar initially in the dialog shown by calling [showDatePicker]. -/// - -const Duration _kMonthScrollDuration = Duration(milliseconds: 200); -const double _kDayPickerRowHeight = 42.0; -const int _kMaxDayPickerRowCount = 6; // A 31 day month that starts on Saturday. -// Two extra rows: one for the day-of-week header and one for the month header. -const double _kMaxDayPickerHeight = - _kDayPickerRowHeight * (_kMaxDayPickerRowCount + 2); - -/// Shows the selected date in large font and toggles between year and day mode -class _DatePickerHeader extends StatelessWidget { - const _DatePickerHeader({ - Key key, - @required this.selectedDate, - @required this.mode, - @required this.onModeChanged, - @required this.orientation, - this.yearSelectAllowed, - this.era, - this.borderRadius, - this.imageHeader, - this.description = "", - this.fontFamily, - }) : assert(selectedDate != null), - assert(mode != null), - assert(orientation != null), - super(key: key); - - final DateTime selectedDate; - final DatePickerMode mode; - final ValueChanged onModeChanged; - final Orientation orientation; - final bool yearSelectAllowed; - - /// Era custom - final EraMode era; - - /// Border - final double borderRadius; - - /// Header - final ImageProvider imageHeader; - - /// Header description - final String description; - - /// Font - final String fontFamily; - - void _handleChangeMode(DatePickerMode value) { - if (value != mode) onModeChanged(value); - } - - @override - Widget build(BuildContext context) { - final MaterialLocalizations localizations = - MaterialLocalizations.of(context); - final ThemeData themeData = Theme.of(context); - final TextTheme headerTextTheme = themeData.primaryTextTheme; - Color dayColor; - Color yearColor; - switch (themeData.primaryColorBrightness) { - case Brightness.light: - dayColor = mode == DatePickerMode.day ? Colors.black87 : Colors.black54; - yearColor = - mode == DatePickerMode.year ? Colors.black87 : Colors.black54; - break; - case Brightness.dark: - dayColor = mode == DatePickerMode.day ? Colors.white : Colors.white70; - yearColor = mode == DatePickerMode.year ? Colors.white : Colors.white70; - break; - } - final TextStyle dayStyle = headerTextTheme.headline4.copyWith( - color: dayColor, fontFamily: fontFamily, fontWeight: FontWeight.w800); - final TextStyle yearStyle = headerTextTheme.subtitle1.copyWith( - color: yearColor, fontFamily: fontFamily, fontWeight: FontWeight.w800); - - Color backgroundColor; - backgroundColor = themeData.primaryColor; - - EdgeInsets padding; - MainAxisAlignment mainAxisAlignment; - switch (orientation) { - case Orientation.portrait: - padding = const EdgeInsets.all(16.0); - mainAxisAlignment = MainAxisAlignment.center; - break; - case Orientation.landscape: - padding = const EdgeInsets.all(8.0); - mainAxisAlignment = MainAxisAlignment.start; - break; - } - - final Widget yearButton = IgnorePointer( - ignoring: mode != DatePickerMode.day, - ignoringSemantics: false, - child: IgnorePointer( - ignoring: !yearSelectAllowed ?? true, - child: _DateHeaderButton( - color: Colors.transparent, - onTap: Feedback.wrapForTap( - () => _handleChangeMode(DatePickerMode.year), - context, - ), - child: Semantics( - selected: mode == DatePickerMode.year, - child: Text( - "${calculateYearEra(era, selectedDate.year)}", - style: yearStyle, - ), - ), - ), - ), - ); - - final Widget dayButton = IgnorePointer( - ignoring: mode == DatePickerMode.day, - ignoringSemantics: false, - child: _DateHeaderButton( - color: Colors.transparent, - onTap: Feedback.wrapForTap( - () => _handleChangeMode(DatePickerMode.day), - context, - ), - child: Semantics( - selected: mode == DatePickerMode.day, - child: Text( - localizations.formatMediumDate(selectedDate), - style: dayStyle, - ), - ), - ), - ); - - BorderRadius borderRadiusData = BorderRadius.only( - topLeft: Radius.circular(borderRadius), - topRight: Radius.circular(borderRadius), - ); - - if (orientation == Orientation.landscape) { - borderRadiusData = BorderRadius.only( - topLeft: Radius.circular(borderRadius), - bottomLeft: Radius.circular(borderRadius), - ); - } - - return Container( - decoration: BoxDecoration( - image: imageHeader != null - ? DecorationImage(image: imageHeader, fit: BoxFit.cover) - : null, - color: backgroundColor, - borderRadius: borderRadiusData, - ), - padding: padding, - child: Column( - mainAxisAlignment: mainAxisAlignment, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - yearButton, - dayButton, - const SizedBox(height: 4.0), - Visibility( - visible: description.isNotEmpty, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Text( - description, - style: TextStyle( - color: yearColor, - fontSize: 12, - fontFamily: fontFamily, - ), - ), - ), - ) - ], - ), - ); - } -} - -class _DateHeaderButton extends StatelessWidget { - const _DateHeaderButton({ - Key key, - this.onTap, - this.color, - this.child, - }) : super(key: key); - - final VoidCallback onTap; - final Color color; - final Widget child; - - @override - Widget build(BuildContext context) { - final ThemeData theme = Theme.of(context); - - return Material( - type: MaterialType.button, - color: color, - child: InkWell( - borderRadius: kMaterialEdges[MaterialType.button], - highlightColor: theme.highlightColor, - splashColor: theme.splashColor, - onTap: onTap, - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: child, - ), - ), - ); - } -} - -class _DayPickerGridDelegate extends SliverGridDelegate { - const _DayPickerGridDelegate(); - - @override - SliverGridLayout getLayout(SliverConstraints constraints) { - const int columnCount = DateTime.daysPerWeek; - final double tileWidth = constraints.crossAxisExtent / columnCount; - final double viewTileHeight = - constraints.viewportMainAxisExtent / (_kMaxDayPickerRowCount + 1); - final double tileHeight = math.max(_kDayPickerRowHeight, viewTileHeight); - - return SliverGridRegularTileLayout( - crossAxisCount: columnCount, - mainAxisStride: tileHeight, - crossAxisStride: tileWidth, - childMainAxisExtent: tileHeight, - childCrossAxisExtent: tileWidth, - reverseCrossAxis: axisDirectionIsReversed(constraints.crossAxisDirection), - ); - } - - @override - bool shouldRelayout(_DayPickerGridDelegate oldDelegate) => false; -} - -const _DayPickerGridDelegate _kDayPickerGridDelegate = _DayPickerGridDelegate(); - -/// Displays the days of a given month and allows choosing a day. -/// -/// The days are arranged in a rectangular grid with one column for each day of -/// the week. -/// -/// The day picker widget is rarely used directly. Instead, consider using -/// [showDatePicker], which creates a date picker dialog. -/// -/// See also: -/// -/// * [showDatePicker], which shows a dialog that contains a material design -/// date picker. -/// * [showTimePicker], which shows a dialog that contains a material design -/// time picker. -class DayPicker extends StatelessWidget { - /// Creates a day picker. - /// - /// Rarely used directly. Instead, typically used as part of a [MonthPicker]. - DayPicker({ - Key key, - @required this.selectedDate, - @required this.currentDate, - @required this.onChanged, - @required this.firstDate, - @required this.lastDate, - @required this.displayedMonth, - this.selectableDayPredicate, - this.dragStartBehavior = DragStartBehavior.start, - this.era, - this.locale, - this.fontFamily, - }) : assert(selectedDate != null), - assert(currentDate != null), - assert(onChanged != null), - assert(displayedMonth != null), - assert(dragStartBehavior != null), - assert(!firstDate.isAfter(lastDate)), - assert(selectedDate.isAfter(firstDate) || - selectedDate.isAtSameMomentAs(firstDate)), - super(key: key); - - /// The currently selected date. - /// - /// This date is highlighted in the picker. - final DateTime selectedDate; - - /// The current date at the time the picker is displayed. - final DateTime currentDate; - - /// Called when the user picks a day. - final ValueChanged onChanged; - - /// The earliest date the user is permitted to pick. - final DateTime firstDate; - - /// The latest date the user is permitted to pick. - final DateTime lastDate; - - /// The month whose days are displayed by this picker. - final DateTime displayedMonth; - - /// Optional user supplied predicate function to customize selectable days. - final SelectableDayPredicate selectableDayPredicate; - - final EraMode era; - final Locale locale; - - final String fontFamily; - - /// Determines the way that drag start behavior is handled. - /// - /// If set to [DragStartBehavior.start], the drag gesture used to scroll a - /// date picker wheel will begin upon the detection of a drag gesture. If set - /// to [DragStartBehavior.down] it will begin when a down event is first - /// detected. - /// - /// In general, setting this to [DragStartBehavior.start] will make drag - /// animation smoother and setting it to [DragStartBehavior.down] will make - /// drag behavior feel slightly more reactive. - /// - /// By default, the drag start behavior is [DragStartBehavior.start]. - /// - /// See also: - /// - /// * [DragGestureRecognizer.dragStartBehavior], which gives an example for the different behaviors. - final DragStartBehavior dragStartBehavior; - - /// Builds widgets showing abbreviated days of week. The first widget in the - /// returned list corresponds to the first day of week for the current locale. - /// - /// Examples: - /// - /// ``` - /// ┌ Sunday is the first day of week in the US (en_US) - /// | - /// S M T W T F S <-- the returned list contains these widgets - /// _ _ _ _ _ 1 2 - /// 3 4 5 6 7 8 9 - /// - /// ┌ But it's Monday in the UK (en_GB) - /// | - /// M T W T F S S <-- the returned list contains these widgets - /// _ _ _ _ 1 2 3 - /// 4 5 6 7 8 9 10 - /// ``` - List _getDayHeaders( - TextStyle headerStyle, - MaterialLocalizations localizations, - ) { - final List result = []; - for (int i = localizations.firstDayOfWeekIndex; true; i = (i + 1) % 7) { - final String weekday = localizations.narrowWeekdays[i]; - result.add(ExcludeSemantics( - child: Center( - child: Text(weekday, - style: TextStyle( - fontWeight: FontWeight.w800, - fontFamily: "HKGrotesk", - color: Color.fromRGBO(78, 62, 253, 1.0)))), - )); - if (i == (localizations.firstDayOfWeekIndex - 1) % 7) break; - } - - return result; - } - -// Do not use this directly - call getDaysInMonth instead. - static const List _daysInMonth = [ - 31, - -1, - 31, - 30, - 31, - 30, - 31, - 31, - 30, - 31, - 30, - 31, - ]; - - /// Returns the number of days in a month, according to the proleptic - /// Gregorian calendar. - /// - /// This applies the leap year logic introduced by the Gregorian reforms of - /// 1582. It will not give valid results for dates prior to that time. - static int getDaysInMonth(int year, int month) { - if (month == DateTime.february) { - final bool isLeapYear = - (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0); - if (isLeapYear) return 29; - return 28; - } - return _daysInMonth[month - 1]; - } - - /// Computes the offset from the first day of week that the first day of the - /// [month] falls on. - /// - /// For example, September 1, 2017 falls on a Friday, which in the calendar - /// localized for United States English appears as: - /// - /// ``` - /// S M T W T F S - /// _ _ _ _ _ 1 2 - /// ``` - /// - /// The offset for the first day of the months is the number of leading blanks - /// in the calendar, i.e. 5. - /// - /// The same date localized for the Russian calendar has a different offset, - /// because the first day of week is Monday rather than Sunday: - /// - /// ``` - /// M T W T F S S - /// _ _ _ _ 1 2 3 - /// ``` - /// - /// So the offset is 4, rather than 5. - /// - /// This code consolidates the following: - /// - /// - [DateTime.weekday] provides a 1-based index into days of week, with 1 - /// falling on Monday. - /// - [MaterialLocalizations.firstDayOfWeekIndex] provides a 0-based index - /// into the [MaterialLocalizations.narrowWeekdays] list. - /// - [MaterialLocalizations.narrowWeekdays] list provides localized names of - /// days of week, always starting with Sunday and ending with Saturday. - int _computeFirstDayOffset( - int year, int month, MaterialLocalizations localizations) { -// 0-based day of week, with 0 representing Monday. - final int weekdayFromMonday = DateTime(year, month).weekday - 1; -// 0-based day of week, with 0 representing Sunday. - final int firstDayOfWeekFromSunday = localizations.firstDayOfWeekIndex; -// firstDayOfWeekFromSunday recomputed to be Monday-based - final int firstDayOfWeekFromMonday = (firstDayOfWeekFromSunday - 1) % 7; -// Number of days between the first day of week appearing on the calendar, -// and the day corresponding to the 1-st of the month. - return (weekdayFromMonday - firstDayOfWeekFromMonday) % 7; - } - - @override - Widget build(BuildContext context) { - final ThemeData themeData = Theme.of(context); - final MaterialLocalizations localizations = - MaterialLocalizations.of(context); - final int year = displayedMonth.year; - final int month = displayedMonth.month; - final int daysInMonth = getDaysInMonth(year, month); - final int firstDayOffset = _computeFirstDayOffset( - year, - month, - localizations, - ); - - final List labels = _getDayHeaders( - themeData.textTheme.caption.copyWith(color: themeData.primaryColor), - localizations); - for (int i = 0; true; i += 1) { -// 1-based day of month, e.g. 1-31 for January, and 1-29 for February on -// a leap year. - final int day = i - firstDayOffset + 1; - if (day > daysInMonth) break; - if (day < 1) { - labels.add(Container()); - } else { - final DateTime dayToBuild = DateTime(year, month, day); - final bool disabled = dayToBuild.isAfter(lastDate) || - dayToBuild.isBefore(firstDate) || - (selectableDayPredicate != null && - !selectableDayPredicate(dayToBuild)); - - BoxDecoration decoration; - TextStyle itemStyle = themeData.textTheme.bodyText2 - .copyWith(fontFamily: fontFamily, fontWeight: FontWeight.w800); - - final bool isSelectedDay = selectedDate.year == year && - selectedDate.month == month && - selectedDate.day == day; - if (isSelectedDay) { -// The selected day gets a circle background highlight, and a contrasting text color. - itemStyle = themeData.accentTextTheme.bodyText1.copyWith( - fontFamily: fontFamily, - fontWeight: FontWeight.w800, - color: Colors.white); - decoration = BoxDecoration( - color: themeData.primaryColor, - shape: BoxShape.circle, - ); - } else if (disabled) { - itemStyle = themeData.textTheme.bodyText2.copyWith( - color: themeData.disabledColor, - fontFamily: fontFamily, - fontWeight: FontWeight.w800, - ); - } else if (currentDate.year == year && - currentDate.month == month && - currentDate.day == day) { -// The current day gets a different text color. - itemStyle = themeData.textTheme.bodyText1.copyWith( - color: themeData.accentColor, - fontFamily: fontFamily, - fontWeight: FontWeight.w800); - } - - Widget dayWidget = Container( - decoration: decoration, - child: Center( - child: Semantics( -// We want the day of month to be spoken first irrespective of the -// locale-specific preferences or TextDirection. This is because -// an accessibility user is more likely to be interested in the -// day of month before the rest of the date, as they are looking -// for the day of month. To do that we prepend day of month to the -// formatted full date. - label: - '${localizations.formatDecimal(day)}, ${localizations.formatFullDate(dayToBuild)}', - selected: isSelectedDay, - sortKey: OrdinalSortKey(day.toDouble()), - child: ExcludeSemantics( - child: Text(localizations.formatDecimal(day), style: itemStyle), - ), - ), - ), - ); - - if (!disabled) { - dayWidget = GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () { - onChanged(dayToBuild); - }, - child: dayWidget, - dragStartBehavior: dragStartBehavior, - ); - } - - labels.add(dayWidget); - } - } - - String monthYearHeader = ""; - monthYearHeader = localizations.formatMonthYear(displayedMonth); - - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: Column( - children: [ - Container( - height: _kDayPickerRowHeight, - child: Center( - child: ExcludeSemantics( - child: Text( - monthYearHeader, - style: themeData.textTheme.subtitle1.copyWith( - fontFamily: fontFamily, fontWeight: FontWeight.w800), - ), - ), - ), - ), - Flexible( - child: GridView.custom( - gridDelegate: _kDayPickerGridDelegate, - childrenDelegate: SliverChildListDelegate( - labels, - addRepaintBoundaries: false, - ), - padding: EdgeInsets.zero, - ), - ), - ], - ), - ); - } -} - -/// A scrollable list of months to allow picking a month. -/// -/// Shows the days of each month in a rectangular grid with one column for each -/// day of the week. -/// -/// The month picker widget is rarely used directly. Instead, consider using -/// [showDatePicker], which creates a date picker dialog. -/// -/// See also: -/// -/// * [showDatePicker], which shows a dialog that contains a material design -/// date picker. -/// * [showTimePicker], which shows a dialog that contains a material design -/// time picker. -class MonthPicker extends StatefulWidget { - /// Creates a month picker. - /// - /// Rarely used directly. Instead, typically used as part of the dialog shown - /// by [showDatePicker]. - MonthPicker({ - Key key, - @required this.selectedDate, - @required this.onChanged, - @required this.firstDate, - @required this.lastDate, - this.selectableDayPredicate, - this.dragStartBehavior = DragStartBehavior.start, - this.era, - this.locale, - this.fontFamily, - }) : assert(selectedDate != null), - assert(onChanged != null), - assert(!firstDate.isAfter(lastDate)), - assert(selectedDate.isAfter(firstDate) || - selectedDate.isAtSameMomentAs(firstDate)), - super(key: key); - - /// The currently selected date. - /// - /// This date is highlighted in the picker. - final DateTime selectedDate; - - /// Called when the user picks a month. - final ValueChanged onChanged; - - /// The earliest date the user is permitted to pick. - final DateTime firstDate; - - /// The latest date the user is permitted to pick. - final DateTime lastDate; - - /// Optional user supplied predicate function to customize selectable days. - final SelectableDayPredicate selectableDayPredicate; - - /// {@macro flutter.widgets.scrollable.dragStartBehavior} - final DragStartBehavior dragStartBehavior; - - /// Optional era year. - final EraMode era; - final Locale locale; - - /// Font - final String fontFamily; - - @override - _MonthPickerState createState() => _MonthPickerState(); -} - -class _MonthPickerState extends State - with SingleTickerProviderStateMixin { - static final Animatable _chevronOpacityTween = - Tween(begin: 1.0, end: 0.0) - .chain(CurveTween(curve: Curves.easeInOut)); - - @override - void initState() { - super.initState(); -// Initially display the pre-selected date. - final int monthPage = _monthDelta(widget.firstDate, widget.selectedDate); - _dayPickerController = PageController(initialPage: monthPage); - _handleMonthPageChanged(monthPage); - _updateCurrentDate(); - -// Setup the fade animation for chevrons - _chevronOpacityController = AnimationController( - duration: const Duration(milliseconds: 250), - vsync: this, - ); - _chevronOpacityAnimation = _chevronOpacityController.drive( - _chevronOpacityTween, - ); - } - - @override - void didUpdateWidget(MonthPicker oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.selectedDate != oldWidget.selectedDate) { - final int monthPage = _monthDelta(widget.firstDate, widget.selectedDate); - _dayPickerController = PageController(initialPage: monthPage); - _handleMonthPageChanged(monthPage); - } - } - - MaterialLocalizations localizations; - TextDirection textDirection; - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - localizations = MaterialLocalizations.of(context); - textDirection = Directionality.of(context); - } - - DateTime _todayDate; - DateTime _currentDisplayedMonthDate; - Timer _timer; - PageController _dayPickerController; - AnimationController _chevronOpacityController; - Animation _chevronOpacityAnimation; - - void _updateCurrentDate() { - _todayDate = DateTime.now(); - final DateTime tomorrow = - DateTime(_todayDate.year, _todayDate.month, _todayDate.day + 1); - Duration timeUntilTomorrow = tomorrow.difference(_todayDate); -// so we don't miss it by rounding - timeUntilTomorrow += const Duration(seconds: 1); - _timer?.cancel(); - _timer = Timer(timeUntilTomorrow, () { - setState(() => _updateCurrentDate()); - }); - } - - static int _monthDelta(DateTime startDate, DateTime endDate) { - return (endDate.year - startDate.year) * 12 + - endDate.month - - startDate.month; - } - - /// Add months to a month truncated date. - DateTime _addMonthsToMonthDate(DateTime monthDate, int monthsToAdd) { - return DateTime( - monthDate.year + monthsToAdd ~/ 12, - monthDate.month + monthsToAdd % 12, - ); - } - - Widget _buildItems(BuildContext context, int index) { - final DateTime month = _addMonthsToMonthDate(widget.firstDate, index); - return DayPicker( - key: ValueKey(month), - selectedDate: widget.selectedDate, - currentDate: _todayDate, - onChanged: widget.onChanged, - firstDate: widget.firstDate, - lastDate: widget.lastDate, - displayedMonth: month, - selectableDayPredicate: widget.selectableDayPredicate, - dragStartBehavior: widget.dragStartBehavior, - era: widget.era, - locale: widget.locale, - fontFamily: widget.fontFamily, - ); - } - - void _handleNextMonth() { - if (!_isDisplayingLastMonth) { - SemanticsService.announce( - localizations.formatMonthYear(_nextMonthDate), - textDirection, - ); - _dayPickerController.nextPage( - duration: _kMonthScrollDuration, - curve: Curves.ease, - ); - } - } - - void _handlePreviousMonth() { - if (!_isDisplayingFirstMonth) { - SemanticsService.announce( - localizations.formatMonthYear(_previousMonthDate), - textDirection, - ); - _dayPickerController.previousPage( - duration: _kMonthScrollDuration, - curve: Curves.ease, - ); - } - } - - /// True if the earliest allowable month is displayed. - bool get _isDisplayingFirstMonth { - return !_currentDisplayedMonthDate.isAfter( - DateTime(widget.firstDate.year, widget.firstDate.month), - ); - } - - /// True if the latest allowable month is displayed. - bool get _isDisplayingLastMonth { - return !_currentDisplayedMonthDate.isBefore( - DateTime(widget.lastDate.year, widget.lastDate.month), - ); - } - - DateTime _previousMonthDate; - DateTime _nextMonthDate; - - void _handleMonthPageChanged(int monthPage) { - setState(() { - _previousMonthDate = _addMonthsToMonthDate( - widget.firstDate, - monthPage - 1, - ); - _currentDisplayedMonthDate = _addMonthsToMonthDate( - widget.firstDate, - monthPage, - ); - _nextMonthDate = _addMonthsToMonthDate(widget.firstDate, monthPage + 1); - }); - } - - @override - Widget build(BuildContext context) { - return SizedBox( -// The month picker just adds month navigation to the day picker, so make -// it the same height as the DayPicker - height: _kMaxDayPickerHeight, - child: Stack( - children: [ - Semantics( - sortKey: _MonthPickerSortKey.calendar, - child: NotificationListener( - onNotification: (_) { - _chevronOpacityController.forward(); - return false; - }, - child: NotificationListener( - onNotification: (_) { - _chevronOpacityController.reverse(); - return false; - }, - child: PageView.builder( - physics: BouncingScrollPhysics(), - dragStartBehavior: widget.dragStartBehavior, - key: ValueKey(widget.selectedDate), - controller: _dayPickerController, - scrollDirection: Axis.horizontal, - itemCount: _monthDelta(widget.firstDate, widget.lastDate) + 1, - itemBuilder: _buildItems, - onPageChanged: _handleMonthPageChanged, - ), - ), - ), - ), - - /// Arrow Left - PositionedDirectional( - top: 0.0, - start: 8.0, - child: Semantics( - sortKey: _MonthPickerSortKey.previousMonth, - child: FadeTransition( - opacity: _chevronOpacityAnimation, - child: IconButton( - disabledColor: - Theme.of(context).disabledColor.withOpacity(0.2), - color: Theme.of(context).disabledColor, - icon: const Icon(Icons.chevron_left_sharp), - tooltip: _isDisplayingFirstMonth - ? null - : '${localizations.previousMonthTooltip} ${localizations.formatMonthYear(_previousMonthDate)}', - onPressed: _isDisplayingFirstMonth == true - ? null - : _handlePreviousMonth, - ), - ), - ), - ), - - /// Arrow Right - PositionedDirectional( - top: 0.0, - end: 8.0, - child: Semantics( - sortKey: _MonthPickerSortKey.nextMonth, - child: FadeTransition( - opacity: _chevronOpacityAnimation, - child: IconButton( - disabledColor: - Theme.of(context).disabledColor.withOpacity(0.2), - color: Theme.of(context).disabledColor, - icon: const Icon(Icons.chevron_right_sharp), - tooltip: _isDisplayingLastMonth - ? null - : '${localizations.nextMonthTooltip} ${localizations.formatMonthYear(_nextMonthDate)}', - onPressed: _isDisplayingLastMonth ? null : _handleNextMonth, - ), - ), - ), - ), - ], - ), - ); - } - - @override - void dispose() { - _timer?.cancel(); - _chevronOpacityController?.dispose(); - _dayPickerController?.dispose(); - super.dispose(); - } -} - -// Defines semantic traversal order of the top-level widgets inside the month -// picker. -class _MonthPickerSortKey extends OrdinalSortKey { - const _MonthPickerSortKey(double order) : super(order); - - static const _MonthPickerSortKey previousMonth = _MonthPickerSortKey(1.0); - static const _MonthPickerSortKey nextMonth = _MonthPickerSortKey(2.0); - static const _MonthPickerSortKey calendar = _MonthPickerSortKey(3.0); -} - -/// A scrollable list of years to allow picking a year. -/// -/// The year picker widget is rarely used directly. Instead, consider using -/// [showDatePicker], which creates a date picker dialog. -/// -/// Requires one of its ancestors to be a [Material] widget. -/// -/// See also: -/// -/// * [showDatePicker], which shows a dialog that contains a material design -/// date picker. -/// * [showTimePicker], which shows a dialog that contains a material design -/// time picker. -class YearPicker extends StatefulWidget { - /// Creates a year picker. - /// - /// The [selectedDate] and [onChanged] arguments must not be null. The - /// [lastDate] must be after the [firstDate]. - /// - /// Rarely used directly. Instead, typically used as part of the dialog shown - /// by [showDatePicker]. - YearPicker({ - Key key, - @required this.selectedDate, - @required this.onChanged, - @required this.firstDate, - @required this.lastDate, - this.era = EraMode.CHRIST_YEAR, - this.fontFamily, - this.dragStartBehavior = DragStartBehavior.start, - }) : assert(selectedDate != null), - assert(onChanged != null), - assert(!firstDate.isAfter(lastDate)), - super(key: key); - - /// The currently selected date. - /// - /// This date is highlighted in the picker. - final DateTime selectedDate; - - /// Called when the user picks a year. - final ValueChanged onChanged; - - /// The earliest date the user is permitted to pick. - final DateTime firstDate; - - /// The latest date the user is permitted to pick. - final DateTime lastDate; - - /// {@macro flutter.widgets.scrollable.dragStartBehavior} - final DragStartBehavior dragStartBehavior; - - /// Era - final EraMode era; - - /// Font - final String fontFamily; - - @override - _YearPickerState createState() => _YearPickerState(); -} - -class _YearPickerState extends State { - static const double _itemExtent = 50.0; - ScrollController scrollController; - - @override - void initState() { - super.initState(); - scrollController = ScrollController( -// Move the initial scroll position to the currently selected date's year. - initialScrollOffset: - (widget.selectedDate.year - widget.firstDate.year) * _itemExtent, - ); - } - - @override - Widget build(BuildContext context) { - assert(debugCheckHasMaterial(context)); - final ThemeData themeData = Theme.of(context); - final TextStyle style = themeData.textTheme.bodyText2 - .copyWith(fontFamily: widget.fontFamily, fontWeight: FontWeight.w700); - return ConstrainedBox( - constraints: BoxConstraints(maxHeight: 300), - child: ListView.builder( - physics: BouncingScrollPhysics(), - dragStartBehavior: widget.dragStartBehavior, - controller: scrollController, - itemExtent: _itemExtent, - itemCount: widget.lastDate.year - widget.firstDate.year + 1, - itemBuilder: (BuildContext context, int index) { - final int year = widget.firstDate.year + index; - final bool isSelected = year == widget.selectedDate.year; - final TextStyle itemStyle = isSelected - ? themeData.textTheme.headline5.copyWith( - color: themeData.accentColor, - fontFamily: widget.fontFamily, - fontWeight: FontWeight.w900) - : style; - return InkWell( - key: ValueKey(year), - onTap: () { - widget.onChanged(DateTime( - year, - widget.selectedDate.month, - widget.selectedDate.day, - )); - }, - child: Center( - child: Semantics( - selected: isSelected, - child: Text( - "${calculateYearEra(widget.era, year)}", - style: itemStyle, - ), - ), - ), - ); - }, - ), - ); - } -} - -class DatePickerDialog extends StatefulWidget { - const DatePickerDialog({ - Key key, - this.initialDate, - this.yearSelectAllowed, - this.firstDate, - this.lastDate, - this.selectableDayPredicate, - this.initialDatePickerMode, - this.era, - this.locale, - this.borderRadius, - this.imageHeader, - this.description = "", - this.fontFamily, - this.negativeBtn, - this.positiveBtn, - this.leftBtn, - this.onLeftBtn, - }) : super(key: key); - - final DateTime initialDate; - final DateTime firstDate; - final DateTime lastDate; - final SelectableDayPredicate selectableDayPredicate; - final DatePickerMode initialDatePickerMode; - final bool yearSelectAllowed; - - /// Custom era year. - final EraMode era; - final Locale locale; - - /// Border - final double borderRadius; - - /// Header; - final ImageProvider imageHeader; - final String description; - - /// Font - final String fontFamily; - - final String negativeBtn; - final String positiveBtn; - final String leftBtn; - final VoidCallback onLeftBtn; - - @override - _DatePickerDialogState createState() => _DatePickerDialogState(); -} - -class _DatePickerDialogState extends State { - @override - void initState() { - super.initState(); - _selectedDate = widget.initialDate; - _mode = widget.initialDatePickerMode; - } - - bool _announcedInitialDate = false; - - MaterialLocalizations localizations; - TextDirection textDirection; - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - localizations = MaterialLocalizations.of(context); - textDirection = Directionality.of(context); - if (!_announcedInitialDate) { - _announcedInitialDate = true; - SemanticsService.announce( - localizations.formatFullDate(_selectedDate), - textDirection, - ); - } - } - - DateTime _selectedDate; - DatePickerMode _mode; - final GlobalKey _pickerKey = GlobalKey(); - - void _vibrate() { - HapticFeedback.vibrate(); - } - - void _handleModeChanged(DatePickerMode mode) { - _vibrate(); - setState(() { - _mode = mode; - if (_mode == DatePickerMode.day) { - SemanticsService.announce( - localizations.formatMonthYear(_selectedDate), - textDirection, - ); - } else { - SemanticsService.announce( - localizations.formatYear(_selectedDate), - textDirection, - ); - } - }); - } - - void _handleYearChanged(DateTime value) { - if (value.isBefore(widget.firstDate)) { - value = widget.firstDate; - } else if (value.isAfter(widget.lastDate)) { - value = widget.lastDate; - } - if (value == _selectedDate) return; - - _vibrate(); - setState(() { - _mode = DatePickerMode.day; - _selectedDate = value; - }); - } - - void _handleDayChanged(DateTime value) { - _vibrate(); - setState(() { - _selectedDate = value; - }); - } - - void _handleOk() { - Navigator.of(context).pop(_selectedDate); - } - - Widget _buildPicker() { - assert(_mode != null); - switch (_mode) { - case DatePickerMode.day: - return MonthPicker( - key: _pickerKey, - selectedDate: _selectedDate, - onChanged: _handleDayChanged, - firstDate: widget.firstDate, - lastDate: widget.lastDate, - era: widget.era, - locale: widget.locale, - selectableDayPredicate: widget.selectableDayPredicate, - fontFamily: widget.fontFamily, - ); - case DatePickerMode.year: - return YearPicker( - key: _pickerKey, - selectedDate: _selectedDate, - onChanged: _handleYearChanged, - firstDate: widget.firstDate, - lastDate: widget.lastDate, - era: widget.era, - fontFamily: widget.fontFamily, - ); - } - return null; - } - - @override - Widget build(BuildContext context) { - final ThemeData theme = Theme.of(context); - final Widget picker = _buildPicker(); - - final Widget actions = ButtonActions(onPositive: _handleOk); - - final Dialog dialog = Dialog( - child: OrientationBuilder( - builder: (BuildContext context, Orientation orientation) { - assert(orientation != null); - final Widget header = _DatePickerHeader( - selectedDate: _selectedDate, - yearSelectAllowed: widget.yearSelectAllowed ?? true, - mode: _mode, - onModeChanged: _handleModeChanged, - orientation: orientation, - era: widget.era, - borderRadius: widget.borderRadius, - imageHeader: widget.imageHeader, - description: widget.description, - fontFamily: widget.fontFamily, - ); - switch (orientation) { - case Orientation.portrait: - return Container( - decoration: BoxDecoration( - color: theme.dialogBackgroundColor, - borderRadius: BorderRadius.circular(widget.borderRadius), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - header, - Flexible(child: picker), - actions, - ], - ), - ); - case Orientation.landscape: - return Container( - decoration: BoxDecoration( - color: theme.dialogBackgroundColor, - borderRadius: BorderRadius.circular(widget.borderRadius), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Flexible(child: header), - Flexible( - flex: 2, - // have the picker take up 2/3 of the dialog width - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Flexible(child: picker), - actions, - ], - ), - ), - ], - ), - ); - } - return null; - }), - ); - - return Theme( - data: theme.copyWith(dialogBackgroundColor: Colors.transparent), - child: dialog, - ); - } -} - -/// Signature for predicating dates for enabled date selections. -/// -/// See [showDatePicker]. -typedef SelectableDayPredicate = bool Function(DateTime day); - -/// Shows a dialog containing a material design date picker. -/// -/// The returned [Future] resolves to the date selected by the user when the -/// user closes the dialog. If the user cancels the dialog, null is returned. -/// -/// An optional [selectableDayPredicate] function can be passed in to customize -/// the days to enable for selection. If provided, only the days that -/// [selectableDayPredicate] returned true for will be selectable. -/// -/// An optional [initialDatePickerMode] argument can be used to display the -/// date picker initially in the year or month+day picker mode. It defaults -/// to month+day, and must not be null. -/// -/// An optional [locale] argument can be used to set the locale for the date -/// picker. It defaults to the ambient locale provided by [Localizations]. -/// -/// An optional [textDirection] argument can be used to set the text direction -/// (RTL or LTR) for the date picker. It defaults to the ambient text direction -/// provided by [Directionality]. If both [locale] and [textDirection] are not -/// null, [textDirection] overrides the direction chosen for the [locale]. -/// -/// The [context] argument is passed to [showDialog], the documentation for -/// which discusses how it is used. -/// -/// The [builder] parameter can be used to wrap the dialog widget -/// to add inherited widgets like [Theme]. -/// -/// {@tool sample} -/// Show a date picker with the dark theme. -/// -/// ```dart -/// Future selectedDate = showDatePicker( -/// context: context, -/// initialDate: DateTime.now(), -/// firstDate: DateTime(2018), -/// lastDate: DateTime(2030), -/// builder: (BuildContext context, Widget child) { -/// return Theme( -/// data: ThemeData.dark(), -/// child: child, -/// ); -/// }, -/// ); -/// ``` -/// {@end-tool} -/// -/// The [context], [initialDate], [firstDate], and [lastDate] parameters must -/// not be null. -/// -/// See also: -/// -/// * [showTimePicker], which shows a dialog that contains a material design -/// time picker. -/// * [DayPicker], which displays the days of a given month and allows -/// choosing a day. -/// * [MonthPicker], which displays a scrollable list of months to allow -/// picking a month. -/// * [YearPicker], which displays a scrollable list of years to allow picking -/// a year. -/// - -Future showRoundedDatePicker( - {@required BuildContext context, - DateTime initialDate, - DateTime firstDate, - DateTime lastDate, - SelectableDayPredicate selectableDayPredicate, - DatePickerMode initialDatePickerMode = DatePickerMode.day, - Locale locale, - TextDirection textDirection, - ThemeData theme, - double borderRadius = 16, - EraMode era = EraMode.CHRIST_YEAR, - ImageProvider imageHeader, - String description = "", - String fontFamily, - bool barrierDismissible = false, - Color background = Colors.transparent, - String negativeBtn, - String positiveBtn, - String leftBtn, - VoidCallback onLeftBtn, - bool yearSelectAllowed}) async { - initialDate ??= DateTime.now(); - firstDate ??= DateTime(initialDate.year - 1); - lastDate ??= DateTime(initialDate.year + 1); - theme ??= ThemeData(); - - assert(initialDate != null); - assert(firstDate != null); - assert(lastDate != null); - assert( - !initialDate.isBefore(firstDate), - 'initialDate must be on or after firstDate', - ); - assert( - !initialDate.isAfter(lastDate), - 'initialDate must be on or before lastDate', - ); - assert( - !firstDate.isAfter(lastDate), - 'lastDate must be on or after firstDate', - ); - assert( - selectableDayPredicate == null || selectableDayPredicate(initialDate), - 'Provided initialDate must satisfy provided selectableDayPredicate', - ); - assert( - initialDatePickerMode != null, - 'initialDatePickerMode must not be null', - ); - assert( - (onLeftBtn != null && leftBtn != null) || onLeftBtn == null, - "If you provide onLeftBtn, you must provide leftBtn", - ); - assert(context != null); - assert(debugCheckHasMaterialLocalizations(context)); - - Widget child = GestureDetector( - onTap: () { - if (!barrierDismissible) { - Navigator.pop(context); - } - }, - child: Container( - color: background, - child: GestureDetector( - onTap: () { -// - }, - child: DatePickerDialog( - initialDate: initialDate, - firstDate: firstDate, - lastDate: lastDate, - yearSelectAllowed: yearSelectAllowed, - selectableDayPredicate: selectableDayPredicate, - initialDatePickerMode: initialDatePickerMode, - era: era, - locale: locale, - borderRadius: borderRadius, - imageHeader: imageHeader, - description: description, - fontFamily: fontFamily, - negativeBtn: negativeBtn, - positiveBtn: positiveBtn, - leftBtn: leftBtn, - onLeftBtn: onLeftBtn, - ), - ), - ), - ); - - if (textDirection != null) { - child = Directionality( - textDirection: textDirection, - child: child, - ); - } - - if (locale != null) { - child = Localizations.override( - context: context, - locale: locale, - child: child, - ); - } - - return await showDialog( - context: context, - barrierDismissible: barrierDismissible, - builder: (_) => Theme(data: theme, child: child), - ); -} +// import 'dart:async'; +// import 'dart:math' as math; +// +// import 'package:flutter/gestures.dart' show DragStartBehavior; +// import 'package:flutter/material.dart'; +// import 'package:flutter/rendering.dart'; +// import 'package:flutter/services.dart'; +// import 'package:flutter/widgets.dart'; +// +// import 'button_actions.dart'; +// import 'era_mode.dart'; +// +// /// Initial display mode of the date picker dialog. +// /// +// /// Date picker UI mode for either showing a list of available years or a +// /// monthly calendar initially in the dialog shown by calling [showDatePicker]. +// /// +// +// const Duration _kMonthScrollDuration = Duration(milliseconds: 200); +// const double _kDayPickerRowHeight = 42.0; +// const int _kMaxDayPickerRowCount = 6; // A 31 day month that starts on Saturday. +// // Two extra rows: one for the day-of-week header and one for the month header. +// const double _kMaxDayPickerHeight = +// _kDayPickerRowHeight * (_kMaxDayPickerRowCount + 2); +// +// /// Shows the selected date in large font and toggles between year and day mode +// class _DatePickerHeader extends StatelessWidget { +// const _DatePickerHeader({ +// Key key, +// @required this.selectedDate, +// @required this.mode, +// @required this.onModeChanged, +// @required this.orientation, +// this.yearSelectAllowed, +// this.era, +// this.borderRadius, +// this.imageHeader, +// this.description = "", +// this.fontFamily, +// }) : assert(selectedDate != null), +// assert(mode != null), +// assert(orientation != null), +// super(key: key); +// +// final DateTime selectedDate; +// final DatePickerMode mode; +// final ValueChanged onModeChanged; +// final Orientation orientation; +// final bool yearSelectAllowed; +// +// /// Era custom +// final EraMode era; +// +// /// Border +// final double borderRadius; +// +// /// Header +// final ImageProvider imageHeader; +// +// /// Header description +// final String description; +// +// /// Font +// final String fontFamily; +// +// void _handleChangeMode(DatePickerMode value) { +// if (value != mode) onModeChanged(value); +// } +// +// @override +// Widget build(BuildContext context) { +// final MaterialLocalizations localizations = +// MaterialLocalizations.of(context); +// final ThemeData themeData = Theme.of(context); +// final TextTheme headerTextTheme = themeData.primaryTextTheme; +// Color dayColor; +// Color yearColor; +// switch (themeData.primaryColorBrightness) { +// case Brightness.light: +// dayColor = mode == DatePickerMode.day ? Colors.black87 : Colors.black54; +// yearColor = +// mode == DatePickerMode.year ? Colors.black87 : Colors.black54; +// break; +// case Brightness.dark: +// dayColor = mode == DatePickerMode.day ? Colors.white : Colors.white70; +// yearColor = mode == DatePickerMode.year ? Colors.white : Colors.white70; +// break; +// } +// final TextStyle dayStyle = headerTextTheme.headline4.copyWith( +// color: dayColor, fontFamily: fontFamily, fontWeight: FontWeight.w800); +// final TextStyle yearStyle = headerTextTheme.subtitle1.copyWith( +// color: yearColor, fontFamily: fontFamily, fontWeight: FontWeight.w800); +// +// Color backgroundColor; +// backgroundColor = themeData.primaryColor; +// +// EdgeInsets padding; +// MainAxisAlignment mainAxisAlignment; +// switch (orientation) { +// case Orientation.portrait: +// padding = const EdgeInsets.all(16.0); +// mainAxisAlignment = MainAxisAlignment.center; +// break; +// case Orientation.landscape: +// padding = const EdgeInsets.all(8.0); +// mainAxisAlignment = MainAxisAlignment.start; +// break; +// } +// +// final Widget yearButton = IgnorePointer( +// ignoring: mode != DatePickerMode.day, +// ignoringSemantics: false, +// child: IgnorePointer( +// ignoring: !yearSelectAllowed ?? true, +// child: _DateHeaderButton( +// color: Colors.transparent, +// onTap: Feedback.wrapForTap( +// () => _handleChangeMode(DatePickerMode.year), +// context, +// ), +// child: Semantics( +// selected: mode == DatePickerMode.year, +// child: Text( +// "${calculateYearEra(era, selectedDate.year)}", +// style: yearStyle, +// ), +// ), +// ), +// ), +// ); +// +// final Widget dayButton = IgnorePointer( +// ignoring: mode == DatePickerMode.day, +// ignoringSemantics: false, +// child: _DateHeaderButton( +// color: Colors.transparent, +// onTap: Feedback.wrapForTap( +// () => _handleChangeMode(DatePickerMode.day), +// context, +// ), +// child: Semantics( +// selected: mode == DatePickerMode.day, +// child: Text( +// localizations.formatMediumDate(selectedDate), +// style: dayStyle, +// ), +// ), +// ), +// ); +// +// BorderRadius borderRadiusData = BorderRadius.only( +// topLeft: Radius.circular(borderRadius), +// topRight: Radius.circular(borderRadius), +// ); +// +// if (orientation == Orientation.landscape) { +// borderRadiusData = BorderRadius.only( +// topLeft: Radius.circular(borderRadius), +// bottomLeft: Radius.circular(borderRadius), +// ); +// } +// +// return Container( +// decoration: BoxDecoration( +// image: imageHeader != null +// ? DecorationImage(image: imageHeader, fit: BoxFit.cover) +// : null, +// color: backgroundColor, +// borderRadius: borderRadiusData, +// ), +// padding: padding, +// child: Column( +// mainAxisAlignment: mainAxisAlignment, +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// yearButton, +// dayButton, +// const SizedBox(height: 4.0), +// Visibility( +// visible: description.isNotEmpty, +// child: Padding( +// padding: EdgeInsets.symmetric(horizontal: 12), +// child: Text( +// description, +// style: TextStyle( +// color: yearColor, +// fontSize: 12, +// fontFamily: fontFamily, +// ), +// ), +// ), +// ) +// ], +// ), +// ); +// } +// } +// +// class _DateHeaderButton extends StatelessWidget { +// const _DateHeaderButton({ +// Key key, +// this.onTap, +// this.color, +// this.child, +// }) : super(key: key); +// +// final VoidCallback onTap; +// final Color color; +// final Widget child; +// +// @override +// Widget build(BuildContext context) { +// final ThemeData theme = Theme.of(context); +// +// return Material( +// type: MaterialType.button, +// color: color, +// child: InkWell( +// borderRadius: kMaterialEdges[MaterialType.button], +// highlightColor: theme.highlightColor, +// splashColor: theme.splashColor, +// onTap: onTap, +// child: Container( +// padding: const EdgeInsets.symmetric(horizontal: 8.0), +// child: child, +// ), +// ), +// ); +// } +// } +// +// class _DayPickerGridDelegate extends SliverGridDelegate { +// const _DayPickerGridDelegate(); +// +// @override +// SliverGridLayout getLayout(SliverConstraints constraints) { +// const int columnCount = DateTime.daysPerWeek; +// final double tileWidth = constraints.crossAxisExtent / columnCount; +// final double viewTileHeight = +// constraints.viewportMainAxisExtent / (_kMaxDayPickerRowCount + 1); +// final double tileHeight = math.max(_kDayPickerRowHeight, viewTileHeight); +// +// return SliverGridRegularTileLayout( +// crossAxisCount: columnCount, +// mainAxisStride: tileHeight, +// crossAxisStride: tileWidth, +// childMainAxisExtent: tileHeight, +// childCrossAxisExtent: tileWidth, +// reverseCrossAxis: axisDirectionIsReversed(constraints.crossAxisDirection), +// ); +// } +// +// @override +// bool shouldRelayout(_DayPickerGridDelegate oldDelegate) => false; +// } +// +// const _DayPickerGridDelegate _kDayPickerGridDelegate = _DayPickerGridDelegate(); +// +// /// Displays the days of a given month and allows choosing a day. +// /// +// /// The days are arranged in a rectangular grid with one column for each day of +// /// the week. +// /// +// /// The day picker widget is rarely used directly. Instead, consider using +// /// [showDatePicker], which creates a date picker dialog. +// /// +// /// See also: +// /// +// /// * [showDatePicker], which shows a dialog that contains a material design +// /// date picker. +// /// * [showTimePicker], which shows a dialog that contains a material design +// /// time picker. +// class DayPicker extends StatelessWidget { +// /// Creates a day picker. +// /// +// /// Rarely used directly. Instead, typically used as part of a [MonthPicker]. +// DayPicker({ +// Key key, +// @required this.selectedDate, +// @required this.currentDate, +// @required this.onChanged, +// @required this.firstDate, +// @required this.lastDate, +// @required this.displayedMonth, +// this.selectableDayPredicate, +// this.dragStartBehavior = DragStartBehavior.start, +// this.era, +// this.locale, +// this.fontFamily, +// }) : assert(selectedDate != null), +// assert(currentDate != null), +// assert(onChanged != null), +// assert(displayedMonth != null), +// assert(dragStartBehavior != null), +// assert(!firstDate.isAfter(lastDate)), +// assert(selectedDate.isAfter(firstDate) || +// selectedDate.isAtSameMomentAs(firstDate)), +// super(key: key); +// +// /// The currently selected date. +// /// +// /// This date is highlighted in the picker. +// final DateTime selectedDate; +// +// /// The current date at the time the picker is displayed. +// final DateTime currentDate; +// +// /// Called when the user picks a day. +// final ValueChanged onChanged; +// +// /// The earliest date the user is permitted to pick. +// final DateTime firstDate; +// +// /// The latest date the user is permitted to pick. +// final DateTime lastDate; +// +// /// The month whose days are displayed by this picker. +// final DateTime displayedMonth; +// +// /// Optional user supplied predicate function to customize selectable days. +// final SelectableDayPredicate selectableDayPredicate; +// +// final EraMode era; +// final Locale locale; +// +// final String fontFamily; +// +// /// Determines the way that drag start behavior is handled. +// /// +// /// If set to [DragStartBehavior.start], the drag gesture used to scroll a +// /// date picker wheel will begin upon the detection of a drag gesture. If set +// /// to [DragStartBehavior.down] it will begin when a down event is first +// /// detected. +// /// +// /// In general, setting this to [DragStartBehavior.start] will make drag +// /// animation smoother and setting it to [DragStartBehavior.down] will make +// /// drag behavior feel slightly more reactive. +// /// +// /// By default, the drag start behavior is [DragStartBehavior.start]. +// /// +// /// See also: +// /// +// /// * [DragGestureRecognizer.dragStartBehavior], which gives an example for the different behaviors. +// final DragStartBehavior dragStartBehavior; +// +// /// Builds widgets showing abbreviated days of week. The first widget in the +// /// returned list corresponds to the first day of week for the current locale. +// /// +// /// Examples: +// /// +// /// ``` +// /// ┌ Sunday is the first day of week in the US (en_US) +// /// | +// /// S M T W T F S <-- the returned list contains these widgets +// /// _ _ _ _ _ 1 2 +// /// 3 4 5 6 7 8 9 +// /// +// /// ┌ But it's Monday in the UK (en_GB) +// /// | +// /// M T W T F S S <-- the returned list contains these widgets +// /// _ _ _ _ 1 2 3 +// /// 4 5 6 7 8 9 10 +// /// ``` +// List _getDayHeaders( +// TextStyle headerStyle, +// MaterialLocalizations localizations, +// ) { +// final List result = []; +// for (int i = localizations.firstDayOfWeekIndex; true; i = (i + 1) % 7) { +// final String weekday = localizations.narrowWeekdays[i]; +// result.add(ExcludeSemantics( +// child: Center( +// child: Text(weekday, +// style: TextStyle( +// fontWeight: FontWeight.w800, +// fontFamily: "HKGrotesk", +// color: Color.fromRGBO(78, 62, 253, 1.0)))), +// )); +// if (i == (localizations.firstDayOfWeekIndex - 1) % 7) break; +// } +// +// return result; +// } +// +// // Do not use this directly - call getDaysInMonth instead. +// static const List _daysInMonth = [ +// 31, +// -1, +// 31, +// 30, +// 31, +// 30, +// 31, +// 31, +// 30, +// 31, +// 30, +// 31, +// ]; +// +// /// Returns the number of days in a month, according to the proleptic +// /// Gregorian calendar. +// /// +// /// This applies the leap year logic introduced by the Gregorian reforms of +// /// 1582. It will not give valid results for dates prior to that time. +// static int getDaysInMonth(int year, int month) { +// if (month == DateTime.february) { +// final bool isLeapYear = +// (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0); +// if (isLeapYear) return 29; +// return 28; +// } +// return _daysInMonth[month - 1]; +// } +// +// /// Computes the offset from the first day of week that the first day of the +// /// [month] falls on. +// /// +// /// For example, September 1, 2017 falls on a Friday, which in the calendar +// /// localized for United States English appears as: +// /// +// /// ``` +// /// S M T W T F S +// /// _ _ _ _ _ 1 2 +// /// ``` +// /// +// /// The offset for the first day of the months is the number of leading blanks +// /// in the calendar, i.e. 5. +// /// +// /// The same date localized for the Russian calendar has a different offset, +// /// because the first day of week is Monday rather than Sunday: +// /// +// /// ``` +// /// M T W T F S S +// /// _ _ _ _ 1 2 3 +// /// ``` +// /// +// /// So the offset is 4, rather than 5. +// /// +// /// This code consolidates the following: +// /// +// /// - [DateTime.weekday] provides a 1-based index into days of week, with 1 +// /// falling on Monday. +// /// - [MaterialLocalizations.firstDayOfWeekIndex] provides a 0-based index +// /// into the [MaterialLocalizations.narrowWeekdays] list. +// /// - [MaterialLocalizations.narrowWeekdays] list provides localized names of +// /// days of week, always starting with Sunday and ending with Saturday. +// int _computeFirstDayOffset( +// int year, int month, MaterialLocalizations localizations) { +// // 0-based day of week, with 0 representing Monday. +// final int weekdayFromMonday = DateTime(year, month).weekday - 1; +// // 0-based day of week, with 0 representing Sunday. +// final int firstDayOfWeekFromSunday = localizations.firstDayOfWeekIndex; +// // firstDayOfWeekFromSunday recomputed to be Monday-based +// final int firstDayOfWeekFromMonday = (firstDayOfWeekFromSunday - 1) % 7; +// // Number of days between the first day of week appearing on the calendar, +// // and the day corresponding to the 1-st of the month. +// return (weekdayFromMonday - firstDayOfWeekFromMonday) % 7; +// } +// +// @override +// Widget build(BuildContext context) { +// final ThemeData themeData = Theme.of(context); +// final MaterialLocalizations localizations = +// MaterialLocalizations.of(context); +// final int year = displayedMonth.year; +// final int month = displayedMonth.month; +// final int daysInMonth = getDaysInMonth(year, month); +// final int firstDayOffset = _computeFirstDayOffset( +// year, +// month, +// localizations, +// ); +// +// final List labels = _getDayHeaders( +// themeData.textTheme.caption.copyWith(color: themeData.primaryColor), +// localizations); +// for (int i = 0; true; i += 1) { +// // 1-based day of month, e.g. 1-31 for January, and 1-29 for February on +// // a leap year. +// final int day = i - firstDayOffset + 1; +// if (day > daysInMonth) break; +// if (day < 1) { +// labels.add(Container()); +// } else { +// final DateTime dayToBuild = DateTime(year, month, day); +// final bool disabled = dayToBuild.isAfter(lastDate) || +// dayToBuild.isBefore(firstDate) || +// (selectableDayPredicate != null && +// !selectableDayPredicate(dayToBuild)); +// +// BoxDecoration decoration; +// TextStyle itemStyle = themeData.textTheme.bodyText2 +// .copyWith(fontFamily: fontFamily, fontWeight: FontWeight.w800); +// +// final bool isSelectedDay = selectedDate.year == year && +// selectedDate.month == month && +// selectedDate.day == day; +// if (isSelectedDay) { +// // The selected day gets a circle background highlight, and a contrasting text color. +// itemStyle = themeData.accentTextTheme.bodyText1.copyWith( +// fontFamily: fontFamily, +// fontWeight: FontWeight.w800, +// color: Colors.white); +// decoration = BoxDecoration( +// color: themeData.primaryColor, +// shape: BoxShape.circle, +// ); +// } else if (disabled) { +// itemStyle = themeData.textTheme.bodyText2.copyWith( +// color: themeData.disabledColor, +// fontFamily: fontFamily, +// fontWeight: FontWeight.w800, +// ); +// } else if (currentDate.year == year && +// currentDate.month == month && +// currentDate.day == day) { +// // The current day gets a different text color. +// itemStyle = themeData.textTheme.bodyText1.copyWith( +// color: themeData.accentColor, +// fontFamily: fontFamily, +// fontWeight: FontWeight.w800); +// } +// +// Widget dayWidget = Container( +// decoration: decoration, +// child: Center( +// child: Semantics( +// // We want the day of month to be spoken first irrespective of the +// // locale-specific preferences or TextDirection. This is because +// // an accessibility user is more likely to be interested in the +// // day of month before the rest of the date, as they are looking +// // for the day of month. To do that we prepend day of month to the +// // formatted full date. +// label: +// '${localizations.formatDecimal(day)}, ${localizations.formatFullDate(dayToBuild)}', +// selected: isSelectedDay, +// sortKey: OrdinalSortKey(day.toDouble()), +// child: ExcludeSemantics( +// child: Text(localizations.formatDecimal(day), style: itemStyle), +// ), +// ), +// ), +// ); +// +// if (!disabled) { +// dayWidget = GestureDetector( +// behavior: HitTestBehavior.opaque, +// onTap: () { +// onChanged(dayToBuild); +// }, +// child: dayWidget, +// dragStartBehavior: dragStartBehavior, +// ); +// } +// +// labels.add(dayWidget); +// } +// } +// +// String monthYearHeader = ""; +// monthYearHeader = localizations.formatMonthYear(displayedMonth); +// +// return Padding( +// padding: const EdgeInsets.symmetric(horizontal: 8.0), +// child: Column( +// children: [ +// Container( +// height: _kDayPickerRowHeight, +// child: Center( +// child: ExcludeSemantics( +// child: Text( +// monthYearHeader, +// style: themeData.textTheme.subtitle1.copyWith( +// fontFamily: fontFamily, fontWeight: FontWeight.w800), +// ), +// ), +// ), +// ), +// Flexible( +// child: GridView.custom( +// gridDelegate: _kDayPickerGridDelegate, +// childrenDelegate: SliverChildListDelegate( +// labels, +// addRepaintBoundaries: false, +// ), +// padding: EdgeInsets.zero, +// ), +// ), +// ], +// ), +// ); +// } +// } +// +// /// A scrollable list of months to allow picking a month. +// /// +// /// Shows the days of each month in a rectangular grid with one column for each +// /// day of the week. +// /// +// /// The month picker widget is rarely used directly. Instead, consider using +// /// [showDatePicker], which creates a date picker dialog. +// /// +// /// See also: +// /// +// /// * [showDatePicker], which shows a dialog that contains a material design +// /// date picker. +// /// * [showTimePicker], which shows a dialog that contains a material design +// /// time picker. +// class MonthPicker extends StatefulWidget { +// /// Creates a month picker. +// /// +// /// Rarely used directly. Instead, typically used as part of the dialog shown +// /// by [showDatePicker]. +// MonthPicker({ +// Key key, +// @required this.selectedDate, +// @required this.onChanged, +// @required this.firstDate, +// @required this.lastDate, +// this.selectableDayPredicate, +// this.dragStartBehavior = DragStartBehavior.start, +// this.era, +// this.locale, +// this.fontFamily, +// }) : assert(selectedDate != null), +// assert(onChanged != null), +// assert(!firstDate.isAfter(lastDate)), +// assert(selectedDate.isAfter(firstDate) || +// selectedDate.isAtSameMomentAs(firstDate)), +// super(key: key); +// +// /// The currently selected date. +// /// +// /// This date is highlighted in the picker. +// final DateTime selectedDate; +// +// /// Called when the user picks a month. +// final ValueChanged onChanged; +// +// /// The earliest date the user is permitted to pick. +// final DateTime firstDate; +// +// /// The latest date the user is permitted to pick. +// final DateTime lastDate; +// +// /// Optional user supplied predicate function to customize selectable days. +// final SelectableDayPredicate selectableDayPredicate; +// +// /// {@macro flutter.widgets.scrollable.dragStartBehavior} +// final DragStartBehavior dragStartBehavior; +// +// /// Optional era year. +// final EraMode era; +// final Locale locale; +// +// /// Font +// final String fontFamily; +// +// @override +// _MonthPickerState createState() => _MonthPickerState(); +// } +// +// class _MonthPickerState extends State +// with SingleTickerProviderStateMixin { +// static final Animatable _chevronOpacityTween = +// Tween(begin: 1.0, end: 0.0) +// .chain(CurveTween(curve: Curves.easeInOut)); +// +// @override +// void initState() { +// super.initState(); +// // Initially display the pre-selected date. +// final int monthPage = _monthDelta(widget.firstDate, widget.selectedDate); +// _dayPickerController = PageController(initialPage: monthPage); +// _handleMonthPageChanged(monthPage); +// _updateCurrentDate(); +// +// // Setup the fade animation for chevrons +// _chevronOpacityController = AnimationController( +// duration: const Duration(milliseconds: 250), +// vsync: this, +// ); +// _chevronOpacityAnimation = _chevronOpacityController.drive( +// _chevronOpacityTween, +// ); +// } +// +// @override +// void didUpdateWidget(MonthPicker oldWidget) { +// super.didUpdateWidget(oldWidget); +// if (widget.selectedDate != oldWidget.selectedDate) { +// final int monthPage = _monthDelta(widget.firstDate, widget.selectedDate); +// _dayPickerController = PageController(initialPage: monthPage); +// _handleMonthPageChanged(monthPage); +// } +// } +// +// MaterialLocalizations localizations; +// TextDirection textDirection; +// +// @override +// void didChangeDependencies() { +// super.didChangeDependencies(); +// localizations = MaterialLocalizations.of(context); +// textDirection = Directionality.of(context); +// } +// +// DateTime _todayDate; +// DateTime _currentDisplayedMonthDate; +// Timer _timer; +// PageController _dayPickerController; +// AnimationController _chevronOpacityController; +// Animation _chevronOpacityAnimation; +// +// void _updateCurrentDate() { +// _todayDate = DateTime.now(); +// final DateTime tomorrow = +// DateTime(_todayDate.year, _todayDate.month, _todayDate.day + 1); +// Duration timeUntilTomorrow = tomorrow.difference(_todayDate); +// // so we don't miss it by rounding +// timeUntilTomorrow += const Duration(seconds: 1); +// _timer?.cancel(); +// _timer = Timer(timeUntilTomorrow, () { +// setState(() => _updateCurrentDate()); +// }); +// } +// +// static int _monthDelta(DateTime startDate, DateTime endDate) { +// return (endDate.year - startDate.year) * 12 + +// endDate.month - +// startDate.month; +// } +// +// /// Add months to a month truncated date. +// DateTime _addMonthsToMonthDate(DateTime monthDate, int monthsToAdd) { +// return DateTime( +// monthDate.year + monthsToAdd ~/ 12, +// monthDate.month + monthsToAdd % 12, +// ); +// } +// +// Widget _buildItems(BuildContext context, int index) { +// final DateTime month = _addMonthsToMonthDate(widget.firstDate, index); +// return DayPicker( +// key: ValueKey(month), +// selectedDate: widget.selectedDate, +// currentDate: _todayDate, +// onChanged: widget.onChanged, +// firstDate: widget.firstDate, +// lastDate: widget.lastDate, +// displayedMonth: month, +// selectableDayPredicate: widget.selectableDayPredicate, +// dragStartBehavior: widget.dragStartBehavior, +// era: widget.era, +// locale: widget.locale, +// fontFamily: widget.fontFamily, +// ); +// } +// +// void _handleNextMonth() { +// if (!_isDisplayingLastMonth) { +// SemanticsService.announce( +// localizations.formatMonthYear(_nextMonthDate), +// textDirection, +// ); +// _dayPickerController.nextPage( +// duration: _kMonthScrollDuration, +// curve: Curves.ease, +// ); +// } +// } +// +// void _handlePreviousMonth() { +// if (!_isDisplayingFirstMonth) { +// SemanticsService.announce( +// localizations.formatMonthYear(_previousMonthDate), +// textDirection, +// ); +// _dayPickerController.previousPage( +// duration: _kMonthScrollDuration, +// curve: Curves.ease, +// ); +// } +// } +// +// /// True if the earliest allowable month is displayed. +// bool get _isDisplayingFirstMonth { +// return !_currentDisplayedMonthDate.isAfter( +// DateTime(widget.firstDate.year, widget.firstDate.month), +// ); +// } +// +// /// True if the latest allowable month is displayed. +// bool get _isDisplayingLastMonth { +// return !_currentDisplayedMonthDate.isBefore( +// DateTime(widget.lastDate.year, widget.lastDate.month), +// ); +// } +// +// DateTime _previousMonthDate; +// DateTime _nextMonthDate; +// +// void _handleMonthPageChanged(int monthPage) { +// setState(() { +// _previousMonthDate = _addMonthsToMonthDate( +// widget.firstDate, +// monthPage - 1, +// ); +// _currentDisplayedMonthDate = _addMonthsToMonthDate( +// widget.firstDate, +// monthPage, +// ); +// _nextMonthDate = _addMonthsToMonthDate(widget.firstDate, monthPage + 1); +// }); +// } +// +// @override +// Widget build(BuildContext context) { +// return SizedBox( +// // The month picker just adds month navigation to the day picker, so make +// // it the same height as the DayPicker +// height: _kMaxDayPickerHeight, +// child: Stack( +// children: [ +// Semantics( +// sortKey: _MonthPickerSortKey.calendar, +// child: NotificationListener( +// onNotification: (_) { +// _chevronOpacityController.forward(); +// return false; +// }, +// child: NotificationListener( +// onNotification: (_) { +// _chevronOpacityController.reverse(); +// return false; +// }, +// child: PageView.builder( +// physics: BouncingScrollPhysics(), +// dragStartBehavior: widget.dragStartBehavior, +// key: ValueKey(widget.selectedDate), +// controller: _dayPickerController, +// scrollDirection: Axis.horizontal, +// itemCount: _monthDelta(widget.firstDate, widget.lastDate) + 1, +// itemBuilder: _buildItems, +// onPageChanged: _handleMonthPageChanged, +// ), +// ), +// ), +// ), +// +// /// Arrow Left +// PositionedDirectional( +// top: 0.0, +// start: 8.0, +// child: Semantics( +// sortKey: _MonthPickerSortKey.previousMonth, +// child: FadeTransition( +// opacity: _chevronOpacityAnimation, +// child: IconButton( +// disabledColor: +// Theme.of(context).disabledColor.withOpacity(0.2), +// color: Theme.of(context).disabledColor, +// icon: const Icon(Icons.chevron_left_sharp), +// tooltip: _isDisplayingFirstMonth +// ? null +// : '${localizations.previousMonthTooltip} ${localizations.formatMonthYear(_previousMonthDate)}', +// onPressed: _isDisplayingFirstMonth == true +// ? null +// : _handlePreviousMonth, +// ), +// ), +// ), +// ), +// +// /// Arrow Right +// PositionedDirectional( +// top: 0.0, +// end: 8.0, +// child: Semantics( +// sortKey: _MonthPickerSortKey.nextMonth, +// child: FadeTransition( +// opacity: _chevronOpacityAnimation, +// child: IconButton( +// disabledColor: +// Theme.of(context).disabledColor.withOpacity(0.2), +// color: Theme.of(context).disabledColor, +// icon: const Icon(Icons.chevron_right_sharp), +// tooltip: _isDisplayingLastMonth +// ? null +// : '${localizations.nextMonthTooltip} ${localizations.formatMonthYear(_nextMonthDate)}', +// onPressed: _isDisplayingLastMonth ? null : _handleNextMonth, +// ), +// ), +// ), +// ), +// ], +// ), +// ); +// } +// +// @override +// void dispose() { +// _timer?.cancel(); +// _chevronOpacityController?.dispose(); +// _dayPickerController?.dispose(); +// super.dispose(); +// } +// } +// +// // Defines semantic traversal order of the top-level widgets inside the month +// // picker. +// class _MonthPickerSortKey extends OrdinalSortKey { +// const _MonthPickerSortKey(double order) : super(order); +// +// static const _MonthPickerSortKey previousMonth = _MonthPickerSortKey(1.0); +// static const _MonthPickerSortKey nextMonth = _MonthPickerSortKey(2.0); +// static const _MonthPickerSortKey calendar = _MonthPickerSortKey(3.0); +// } +// +// /// A scrollable list of years to allow picking a year. +// /// +// /// The year picker widget is rarely used directly. Instead, consider using +// /// [showDatePicker], which creates a date picker dialog. +// /// +// /// Requires one of its ancestors to be a [Material] widget. +// /// +// /// See also: +// /// +// /// * [showDatePicker], which shows a dialog that contains a material design +// /// date picker. +// /// * [showTimePicker], which shows a dialog that contains a material design +// /// time picker. +// class YearPicker extends StatefulWidget { +// /// Creates a year picker. +// /// +// /// The [selectedDate] and [onChanged] arguments must not be null. The +// /// [lastDate] must be after the [firstDate]. +// /// +// /// Rarely used directly. Instead, typically used as part of the dialog shown +// /// by [showDatePicker]. +// YearPicker({ +// Key key, +// @required this.selectedDate, +// @required this.onChanged, +// @required this.firstDate, +// @required this.lastDate, +// this.era = EraMode.CHRIST_YEAR, +// this.fontFamily, +// this.dragStartBehavior = DragStartBehavior.start, +// }) : assert(selectedDate != null), +// assert(onChanged != null), +// assert(!firstDate.isAfter(lastDate)), +// super(key: key); +// +// /// The currently selected date. +// /// +// /// This date is highlighted in the picker. +// final DateTime selectedDate; +// +// /// Called when the user picks a year. +// final ValueChanged onChanged; +// +// /// The earliest date the user is permitted to pick. +// final DateTime firstDate; +// +// /// The latest date the user is permitted to pick. +// final DateTime lastDate; +// +// /// {@macro flutter.widgets.scrollable.dragStartBehavior} +// final DragStartBehavior dragStartBehavior; +// +// /// Era +// final EraMode era; +// +// /// Font +// final String fontFamily; +// +// @override +// _YearPickerState createState() => _YearPickerState(); +// } +// +// class _YearPickerState extends State { +// static const double _itemExtent = 50.0; +// ScrollController scrollController; +// +// @override +// void initState() { +// super.initState(); +// scrollController = ScrollController( +// // Move the initial scroll position to the currently selected date's year. +// initialScrollOffset: +// (widget.selectedDate.year - widget.firstDate.year) * _itemExtent, +// ); +// } +// +// @override +// Widget build(BuildContext context) { +// assert(debugCheckHasMaterial(context)); +// final ThemeData themeData = Theme.of(context); +// final TextStyle style = themeData.textTheme.bodyText2 +// .copyWith(fontFamily: widget.fontFamily, fontWeight: FontWeight.w700); +// return ConstrainedBox( +// constraints: BoxConstraints(maxHeight: 300), +// child: ListView.builder( +// physics: BouncingScrollPhysics(), +// dragStartBehavior: widget.dragStartBehavior, +// controller: scrollController, +// itemExtent: _itemExtent, +// itemCount: widget.lastDate.year - widget.firstDate.year + 1, +// itemBuilder: (BuildContext context, int index) { +// final int year = widget.firstDate.year + index; +// final bool isSelected = year == widget.selectedDate.year; +// final TextStyle itemStyle = isSelected +// ? themeData.textTheme.headline5.copyWith( +// color: themeData.accentColor, +// fontFamily: widget.fontFamily, +// fontWeight: FontWeight.w900) +// : style; +// return InkWell( +// key: ValueKey(year), +// onTap: () { +// widget.onChanged(DateTime( +// year, +// widget.selectedDate.month, +// widget.selectedDate.day, +// )); +// }, +// child: Center( +// child: Semantics( +// selected: isSelected, +// child: Text( +// "${calculateYearEra(widget.era, year)}", +// style: itemStyle, +// ), +// ), +// ), +// ); +// }, +// ), +// ); +// } +// } +// +// class DatePickerDialog extends StatefulWidget { +// const DatePickerDialog({ +// Key key, +// this.initialDate, +// this.yearSelectAllowed, +// this.firstDate, +// this.lastDate, +// this.selectableDayPredicate, +// this.initialDatePickerMode, +// this.era, +// this.locale, +// this.borderRadius, +// this.imageHeader, +// this.description = "", +// this.fontFamily, +// this.negativeBtn, +// this.positiveBtn, +// this.leftBtn, +// this.onLeftBtn, +// }) : super(key: key); +// +// final DateTime initialDate; +// final DateTime firstDate; +// final DateTime lastDate; +// final SelectableDayPredicate selectableDayPredicate; +// final DatePickerMode initialDatePickerMode; +// final bool yearSelectAllowed; +// +// /// Custom era year. +// final EraMode era; +// final Locale locale; +// +// /// Border +// final double borderRadius; +// +// /// Header; +// final ImageProvider imageHeader; +// final String description; +// +// /// Font +// final String fontFamily; +// +// final String negativeBtn; +// final String positiveBtn; +// final String leftBtn; +// final VoidCallback onLeftBtn; +// +// @override +// _DatePickerDialogState createState() => _DatePickerDialogState(); +// } +// +// class _DatePickerDialogState extends State { +// @override +// void initState() { +// super.initState(); +// _selectedDate = widget.initialDate; +// _mode = widget.initialDatePickerMode; +// } +// +// bool _announcedInitialDate = false; +// +// MaterialLocalizations localizations; +// TextDirection textDirection; +// +// @override +// void didChangeDependencies() { +// super.didChangeDependencies(); +// localizations = MaterialLocalizations.of(context); +// textDirection = Directionality.of(context); +// if (!_announcedInitialDate) { +// _announcedInitialDate = true; +// SemanticsService.announce( +// localizations.formatFullDate(_selectedDate), +// textDirection, +// ); +// } +// } +// +// DateTime _selectedDate; +// DatePickerMode _mode; +// final GlobalKey _pickerKey = GlobalKey(); +// +// void _vibrate() { +// HapticFeedback.vibrate(); +// } +// +// void _handleModeChanged(DatePickerMode mode) { +// _vibrate(); +// setState(() { +// _mode = mode; +// if (_mode == DatePickerMode.day) { +// SemanticsService.announce( +// localizations.formatMonthYear(_selectedDate), +// textDirection, +// ); +// } else { +// SemanticsService.announce( +// localizations.formatYear(_selectedDate), +// textDirection, +// ); +// } +// }); +// } +// +// void _handleYearChanged(DateTime value) { +// if (value.isBefore(widget.firstDate)) { +// value = widget.firstDate; +// } else if (value.isAfter(widget.lastDate)) { +// value = widget.lastDate; +// } +// if (value == _selectedDate) return; +// +// _vibrate(); +// setState(() { +// _mode = DatePickerMode.day; +// _selectedDate = value; +// }); +// } +// +// void _handleDayChanged(DateTime value) { +// _vibrate(); +// setState(() { +// _selectedDate = value; +// }); +// } +// +// void _handleOk() { +// Navigator.of(context).pop(_selectedDate); +// } +// +// Widget _buildPicker() { +// assert(_mode != null); +// switch (_mode) { +// case DatePickerMode.day: +// return MonthPicker( +// key: _pickerKey, +// selectedDate: _selectedDate, +// onChanged: _handleDayChanged, +// firstDate: widget.firstDate, +// lastDate: widget.lastDate, +// era: widget.era, +// locale: widget.locale, +// selectableDayPredicate: widget.selectableDayPredicate, +// fontFamily: widget.fontFamily, +// ); +// case DatePickerMode.year: +// return YearPicker( +// key: _pickerKey, +// selectedDate: _selectedDate, +// onChanged: _handleYearChanged, +// firstDate: widget.firstDate, +// lastDate: widget.lastDate, +// era: widget.era, +// fontFamily: widget.fontFamily, +// ); +// } +// return null; +// } +// +// @override +// Widget build(BuildContext context) { +// final ThemeData theme = Theme.of(context); +// final Widget picker = _buildPicker(); +// +// final Widget actions = ButtonActions(onPositive: _handleOk); +// +// final Dialog dialog = Dialog( +// child: OrientationBuilder( +// builder: (BuildContext context, Orientation orientation) { +// assert(orientation != null); +// final Widget header = _DatePickerHeader( +// selectedDate: _selectedDate, +// yearSelectAllowed: widget.yearSelectAllowed ?? true, +// mode: _mode, +// onModeChanged: _handleModeChanged, +// orientation: orientation, +// era: widget.era, +// borderRadius: widget.borderRadius, +// imageHeader: widget.imageHeader, +// description: widget.description, +// fontFamily: widget.fontFamily, +// ); +// switch (orientation) { +// case Orientation.portrait: +// return Container( +// decoration: BoxDecoration( +// color: theme.dialogBackgroundColor, +// borderRadius: BorderRadius.circular(widget.borderRadius), +// ), +// child: Column( +// mainAxisSize: MainAxisSize.min, +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// header, +// Flexible(child: picker), +// actions, +// ], +// ), +// ); +// case Orientation.landscape: +// return Container( +// decoration: BoxDecoration( +// color: theme.dialogBackgroundColor, +// borderRadius: BorderRadius.circular(widget.borderRadius), +// ), +// child: Row( +// mainAxisSize: MainAxisSize.min, +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// Flexible(child: header), +// Flexible( +// flex: 2, +// // have the picker take up 2/3 of the dialog width +// child: Column( +// mainAxisSize: MainAxisSize.min, +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// Flexible(child: picker), +// actions, +// ], +// ), +// ), +// ], +// ), +// ); +// } +// return null; +// }), +// ); +// +// return Theme( +// data: theme.copyWith(dialogBackgroundColor: Colors.transparent), +// child: dialog, +// ); +// } +// } +// +// /// Signature for predicating dates for enabled date selections. +// /// +// /// See [showDatePicker]. +// typedef SelectableDayPredicate = bool Function(DateTime day); +// +// /// Shows a dialog containing a material design date picker. +// /// +// /// The returned [Future] resolves to the date selected by the user when the +// /// user closes the dialog. If the user cancels the dialog, null is returned. +// /// +// /// An optional [selectableDayPredicate] function can be passed in to customize +// /// the days to enable for selection. If provided, only the days that +// /// [selectableDayPredicate] returned true for will be selectable. +// /// +// /// An optional [initialDatePickerMode] argument can be used to display the +// /// date picker initially in the year or month+day picker mode. It defaults +// /// to month+day, and must not be null. +// /// +// /// An optional [locale] argument can be used to set the locale for the date +// /// picker. It defaults to the ambient locale provided by [Localizations]. +// /// +// /// An optional [textDirection] argument can be used to set the text direction +// /// (RTL or LTR) for the date picker. It defaults to the ambient text direction +// /// provided by [Directionality]. If both [locale] and [textDirection] are not +// /// null, [textDirection] overrides the direction chosen for the [locale]. +// /// +// /// The [context] argument is passed to [showDialog], the documentation for +// /// which discusses how it is used. +// /// +// /// The [builder] parameter can be used to wrap the dialog widget +// /// to add inherited widgets like [Theme]. +// /// +// /// {@tool sample} +// /// Show a date picker with the dark theme. +// /// +// /// ```dart +// /// Future selectedDate = showDatePicker( +// /// context: context, +// /// initialDate: DateTime.now(), +// /// firstDate: DateTime(2018), +// /// lastDate: DateTime(2030), +// /// builder: (BuildContext context, Widget child) { +// /// return Theme( +// /// data: ThemeData.dark(), +// /// child: child, +// /// ); +// /// }, +// /// ); +// /// ``` +// /// {@end-tool} +// /// +// /// The [context], [initialDate], [firstDate], and [lastDate] parameters must +// /// not be null. +// /// +// /// See also: +// /// +// /// * [showTimePicker], which shows a dialog that contains a material design +// /// time picker. +// /// * [DayPicker], which displays the days of a given month and allows +// /// choosing a day. +// /// * [MonthPicker], which displays a scrollable list of months to allow +// /// picking a month. +// /// * [YearPicker], which displays a scrollable list of years to allow picking +// /// a year. +// /// +// +// Future showRoundedDatePicker( +// {@required BuildContext context, +// DateTime initialDate, +// DateTime firstDate, +// DateTime lastDate, +// SelectableDayPredicate selectableDayPredicate, +// DatePickerMode initialDatePickerMode = DatePickerMode.day, +// Locale locale, +// TextDirection textDirection, +// ThemeData theme, +// double borderRadius = 16, +// EraMode era = EraMode.CHRIST_YEAR, +// ImageProvider imageHeader, +// String description = "", +// String fontFamily, +// bool barrierDismissible = false, +// Color background = Colors.transparent, +// String negativeBtn, +// String positiveBtn, +// String leftBtn, +// VoidCallback onLeftBtn, +// bool yearSelectAllowed}) async { +// initialDate ??= DateTime.now(); +// firstDate ??= DateTime(initialDate.year - 1); +// lastDate ??= DateTime(initialDate.year + 1); +// theme ??= ThemeData(); +// +// assert(initialDate != null); +// assert(firstDate != null); +// assert(lastDate != null); +// assert( +// !initialDate.isBefore(firstDate), +// 'initialDate must be on or after firstDate', +// ); +// assert( +// !initialDate.isAfter(lastDate), +// 'initialDate must be on or before lastDate', +// ); +// assert( +// !firstDate.isAfter(lastDate), +// 'lastDate must be on or after firstDate', +// ); +// assert( +// selectableDayPredicate == null || selectableDayPredicate(initialDate), +// 'Provided initialDate must satisfy provided selectableDayPredicate', +// ); +// assert( +// initialDatePickerMode != null, +// 'initialDatePickerMode must not be null', +// ); +// assert( +// (onLeftBtn != null && leftBtn != null) || onLeftBtn == null, +// "If you provide onLeftBtn, you must provide leftBtn", +// ); +// assert(context != null); +// assert(debugCheckHasMaterialLocalizations(context)); +// +// Widget child = GestureDetector( +// onTap: () { +// if (!barrierDismissible) { +// Navigator.pop(context); +// } +// }, +// child: Container( +// color: background, +// child: GestureDetector( +// onTap: () { +// // +// }, +// child: DatePickerDialog( +// initialDate: initialDate, +// firstDate: firstDate, +// lastDate: lastDate, +// yearSelectAllowed: yearSelectAllowed, +// selectableDayPredicate: selectableDayPredicate, +// initialDatePickerMode: initialDatePickerMode, +// era: era, +// locale: locale, +// borderRadius: borderRadius, +// imageHeader: imageHeader, +// description: description, +// fontFamily: fontFamily, +// negativeBtn: negativeBtn, +// positiveBtn: positiveBtn, +// leftBtn: leftBtn, +// onLeftBtn: onLeftBtn, +// ), +// ), +// ), +// ); +// +// if (textDirection != null) { +// child = Directionality( +// textDirection: textDirection, +// child: child, +// ); +// } +// +// if (locale != null) { +// child = Localizations.override( +// context: context, +// locale: locale, +// child: child, +// ); +// } +// +// return await showDialog( +// context: context, +// barrierDismissible: barrierDismissible, +// builder: (_) => Theme(data: theme, child: child), +// ); +// } diff --git a/lib/widgets/input/text_field.dart b/lib/widgets/input/text_field.dart index 9b9947ea..f4637a28 100644 --- a/lib/widgets/input/text_field.dart +++ b/lib/widgets/input/text_field.dart @@ -37,262 +37,262 @@ class NumberTextInputFormatter extends TextInputFormatter { final _mobileFormatter = NumberTextInputFormatter(); -class TextFields extends StatefulWidget { - TextFields( - {Key key, - this.type, - this.hintText, - this.suffixIcon, - this.autoFocus, - this.onChanged, - this.initialValue, - this.minLines, - this.maxLines, - this.inputFormatters, - this.padding, - this.focus = false, - this.maxLengthEnforced = true, - this.suffixIconColor, - this.inputAction, - this.onSubmit, - this.keepPadding = true, - this.textCapitalization = TextCapitalization.none, - this.controller, - this.keyboardType, - this.validator, - this.borderOnlyError = false, - this.onSaved, - this.onSuffixTap, - this.readOnly: false, - this.maxLength, - this.prefixIcon, - this.bare = false, - this.onTap, - this.fontSize = 16.0, - this.fontWeight = FontWeight.w700, - this.fillColor, - this.hintColor}) - : super(key: key); - - final String hintText; - final String initialValue; - final String type; - final bool autoFocus; - final IconData suffixIcon; - final Color suffixIconColor; - final Icon prefixIcon; - final VoidCallback onTap; - final TextEditingController controller; - final TextInputType keyboardType; - final FormFieldValidator validator; - final Function onSaved; - final Function onSuffixTap; - final Function onChanged; - final Function onSubmit; - final bool readOnly; - final int maxLength; - final int minLines; - final int maxLines; - final bool maxLengthEnforced; - final bool bare; - final TextInputAction inputAction; - final double fontSize; - final FontWeight fontWeight; - final bool keepPadding; - final TextCapitalization textCapitalization; - final List inputFormatters; - final EdgeInsets padding; - final bool focus; - final bool borderOnlyError; - final Color hintColor; - final Color fillColor; - - @override - _TextFieldsState createState() => _TextFieldsState(); -} - -class _TextFieldsState extends State { - final FocusNode _focusNode = FocusNode(); - bool focus = false; - bool view = false; - - @override - void initState() { - super.initState(); - _focusNode.addListener(() { - setState(() { - focus = _focusNode.hasFocus; - }); - }); - } - - @override - void didUpdateWidget(TextFields oldWidget) { - if (widget.focus) _focusNode.requestFocus(); - super.didUpdateWidget(oldWidget); - } - - @override - void dispose() { - _focusNode.dispose(); - super.dispose(); - } - - Widget _buildSuffixIcon() { - switch (widget.type) { - case "password": - return Padding( - padding: const EdgeInsets.only(right: 8.0), - child: view - ? InkWell( - onTap: () { - this.setState( - () { - view = false; - }, - ); - }, - child: Icon( - Icons.remove_red_eye_sharp, - size: 24.0, - color: Color.fromRGBO(78, 62, 253, 1.0), - ), - ) - : InkWell( - onTap: () { - this.setState(() { - view = true; - }); - }, - child: Icon(Icons.remove_red_eye_sharp, - size: 24.0, color: Colors.grey[500]), - ), - ); - default: - if (widget.suffixIcon != null) - return InkWell( - onTap: widget.onSuffixTap, - child: Icon(widget.suffixIcon, - size: 22.0, - color: widget.suffixIconColor != null - ? widget.suffixIconColor - : Colors.grey[500]), - ); - else - return null; - } - } - - bool _determineReadOnly() { - if (widget.readOnly != null && widget.readOnly) { - _focusNode.unfocus(); - return true; - } else { - return false; - } - } - - @override - Widget build(BuildContext context) { - return (AnimatedContainer( - duration: Duration(milliseconds: 300), - decoration: widget.bare - ? null - : BoxDecoration(boxShadow: [ - // BoxShadow( - // color: Color.fromRGBO(70, 68, 167, focus ? 0.20 : 0), - // offset: Offset(0.0, 13.0), - // blurRadius: focus ? 34.0 : 12.0) - BoxShadow( - color: Color.fromRGBO(110, 68, 80, focus ? 0.20 : 0), - offset: Offset(0.0, 13.0), - blurRadius: focus ? 34.0 : 12.0) - ]), - child: TextFormField( - keyboardAppearance: Theme.of(context).brightness, - scrollPhysics: BouncingScrollPhysics(), - textCapitalization: widget.textCapitalization, - onFieldSubmitted: widget.inputAction == TextInputAction.next - ? (widget.onSubmit != null - ? widget.onSubmit - : (val) { - _focusNode.nextFocus(); - }) - : widget.onSubmit, - textInputAction: widget.inputAction, - minLines: widget.minLines ?? 1, - maxLines: widget.maxLines ?? 1, - // maxLengthEnforcement: widget.maxLengthEnforced, - initialValue: widget.initialValue, - onChanged: widget.onChanged, - focusNode: _focusNode, - maxLength: widget.maxLength ?? null, - controller: widget.controller, - keyboardType: widget.keyboardType, - readOnly: _determineReadOnly(), - obscureText: widget.type == "password" && !view ? true : false, - autofocus: widget.autoFocus ?? false, - validator: widget.validator, - onSaved: widget.onSaved, - style: Theme.of(context) - .textTheme - .bodyText1 - .copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight), - inputFormatters: widget.keyboardType == TextInputType.phone - ? [ - FilteringTextInputFormatter.digitsOnly, - _mobileFormatter, - ] - : widget.inputFormatters, - decoration: InputDecoration( - counterText: "", - hintText: widget.hintText, - hintStyle: TextStyle( - fontSize: widget.fontSize, - fontWeight: widget.fontWeight, - color: widget.hintColor ?? Theme.of(context).hintColor, - ), - contentPadding: widget.padding != null - ? widget.padding - : EdgeInsets.symmetric( - vertical: (widget.bare && !widget.keepPadding) ? 0.0 : 10.0, - horizontal: 16.0), - filled: true, - fillColor: widget.bare - ? Colors.transparent - : Theme.of(context).backgroundColor, - suffixIcon: _buildSuffixIcon(), - prefixIcon: widget.prefixIcon, - errorStyle: TextStyle( - fontSize: 14.0, - fontWeight: widget.fontWeight, - height: widget.borderOnlyError ? 0.0 : null), - errorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context) - .errorColor - .withOpacity(widget.bare ? 0.0 : 0.5), - width: 1.0), - borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), - focusedErrorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context) - .errorColor - .withOpacity(widget.bare ? 0.0 : 0.5), - width: 1.0), - borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 1.0), - borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 1.0), - borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 1.0), - borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0), - ), - ), - ), - )); - } -} +// class TextFields extends StatefulWidget { +// TextFields( +// {Key? key, +// this.type, +// this.hintText, +// this.suffixIcon, +// this.autoFocus, +// this.onChanged, +// this.initialValue, +// this.minLines, +// this.maxLines, +// this.inputFormatters, +// this.padding, +// this.focus = false, +// this.maxLengthEnforced = true, +// this.suffixIconColor, +// this.inputAction, +// this.onSubmit, +// this.keepPadding = true, +// this.textCapitalization = TextCapitalization.none, +// this.controller, +// this.keyboardType, +// this.validator, +// this.borderOnlyError = false, +// this.onSaved, +// this.onSuffixTap, +// this.readOnly= false, +// this.maxLength, +// this.prefixIcon, +// this.bare = false, +// this.onTap, +// this.fontSize = 16.0, +// this.fontWeight = FontWeight.w700, +// this.fillColor, +// this.hintColor}) +// : super(key: key); +// +// final String? hintText; +// final String? initialValue; +// final String? type; +// final bool? autoFocus; +// final IconData? suffixIcon; +// final Color? suffixIconColor; +// final Icon? prefixIcon; +// final VoidCallback? onTap; +// final TextEditingController? controller; +// final TextInputType? keyboardType; +// final FormFieldValidator? validator; +// final Function? onSaved; +// final Function? onSuffixTap; +// final Function? onChanged; +// final Function? onSubmit; +// final bool? readOnly; +// final int? maxLength; +// final int? minLines; +// final int? maxLines; +// final bool? maxLengthEnforced; +// final bool? bare; +// final TextInputAction? inputAction; +// final double? fontSize; +// final FontWeight? fontWeight; +// final bool? keepPadding; +// final TextCapitalization? textCapitalization; +// final List? inputFormatters; +// final EdgeInsets? padding; +// final bool? focus; +// final bool? borderOnlyError; +// final Color? hintColor; +// final Color? fillColor; +// +// @override +// _TextFieldsState createState() => _TextFieldsState(); +// } +// +// class _TextFieldsState extends State { +// final FocusNode _focusNode = FocusNode(); +// bool? focus = false; +// bool? view = false; +// +// @override +// void initState() { +// super.initState(); +// _focusNode.addListener(() { +// setState(() { +// focus = _focusNode.hasFocus; +// }); +// }); +// } +// +// @override +// void didUpdateWidget(TextFields oldWidget) { +// if (widget.focus != null) _focusNode.requestFocus(); +// super.didUpdateWidget(oldWidget); +// } +// +// @override +// void dispose() { +// _focusNode.dispose(); +// super.dispose(); +// } +// +// Widget _buildSuffixIcon() { +// switch (widget.type) { +// case "password": +// return Padding( +// padding: const EdgeInsets.only(right: 8.0), +// child: view! +// ? InkWell( +// onTap: () { +// this.setState( +// () { +// view = false; +// }, +// ); +// }, +// child: Icon( +// Icons.remove_red_eye_sharp, +// size: 24.0, +// color: Color.fromRGBO(78, 62, 253, 1.0), +// ), +// ) +// : InkWell( +// onTap: () { +// this.setState(() { +// view = true; +// }); +// }, +// child: Icon(Icons.remove_red_eye_sharp, +// size: 24.0, color: Colors.grey[500]), +// ), +// ); +// default: +// if (widget.suffixIcon != null) +// return InkWell( +// onTap: widget.onSuffixTap, +// child: Icon(widget.suffixIcon, +// size: 22.0, +// color: widget.suffixIconColor != null +// ? widget.suffixIconColor +// : Colors.grey[500]), +// ); +// else +// return null; +// } +// } +// +// bool _determineReadOnly() { +// if (widget.readOnly != null && widget.readOnly!) { +// _focusNode.unfocus(); +// return true; +// } else { +// return false; +// } +// } +// +// @override +// Widget build(BuildContext context) { +// return (AnimatedContainer( +// duration: Duration(milliseconds: 300), +// decoration: widget.bare! +// ? null +// : BoxDecoration(boxShadow: [ +// // BoxShadow( +// // color: Color.fromRGBO(70, 68, 167, focus ? 0.20 : 0), +// // offset: Offset(0.0, 13.0), +// // blurRadius: focus ? 34.0 : 12.0) +// BoxShadow( +// color: Color.fromRGBO(110, 68, 80, focus ? 0.20 : 0), +// offset: Offset(0.0, 13.0), +// blurRadius: focus ? 34.0 : 12.0) +// ]), +// child: TextFormField( +// keyboardAppearance: Theme.of(context).brightness, +// scrollPhysics: BouncingScrollPhysics(), +// textCapitalization: widget.textCapitalization, +// onFieldSubmitted: widget.inputAction == TextInputAction.next +// ? (widget.onSubmit != null +// ? widget.onSubmit +// : (val) { +// _focusNode.nextFocus(); +// }) +// : widget.onSubmit, +// textInputAction: widget.inputAction, +// minLines: widget.minLines ?? 1, +// maxLines: widget.maxLines ?? 1, +// // maxLengthEnforcement: widget.maxLengthEnforced, +// initialValue: widget.initialValue, +// onChanged: widget.onChanged, +// focusNode: _focusNode, +// maxLength: widget.maxLength ?? null, +// controller: widget.controller, +// keyboardType: widget.keyboardType, +// readOnly: _determineReadOnly(), +// obscureText: widget.type == "password" && !view ? true : false, +// autofocus: widget.autoFocus ?? false, +// validator: widget.validator, +// onSaved: widget.onSaved, +// style: Theme.of(context) +// .textTheme +// .bodyText1 +// .copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight), +// inputFormatters: widget.keyboardType == TextInputType.phone +// ? [ +// FilteringTextInputFormatter.digitsOnly, +// _mobileFormatter, +// ] +// : widget.inputFormatters, +// decoration: InputDecoration( +// counterText: "", +// hintText: widget.hintText, +// hintStyle: TextStyle( +// fontSize: widget.fontSize, +// fontWeight: widget.fontWeight, +// color: widget.hintColor ?? Theme.of(context).hintColor, +// ), +// contentPadding: widget.padding != null +// ? widget.padding +// : EdgeInsets.symmetric( +// vertical: (widget.bare && !widget.keepPadding) ? 0.0 : 10.0, +// horizontal: 16.0), +// filled: true, +// fillColor: widget.bare +// ? Colors.transparent +// : Theme.of(context).backgroundColor, +// suffixIcon: _buildSuffixIcon(), +// prefixIcon: widget.prefixIcon, +// errorStyle: TextStyle( +// fontSize: 14.0, +// fontWeight: widget.fontWeight, +// height: widget.borderOnlyError ? 0.0 : null), +// errorBorder: OutlineInputBorder( +// borderSide: BorderSide( +// color: Theme.of(context) +// .errorColor +// .withOpacity(widget.bare ? 0.0 : 0.5), +// width: 1.0), +// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), +// focusedErrorBorder: OutlineInputBorder( +// borderSide: BorderSide( +// color: Theme.of(context) +// .errorColor +// .withOpacity(widget.bare ? 0.0 : 0.5), +// width: 1.0), +// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), +// focusedBorder: OutlineInputBorder( +// borderSide: BorderSide(color: Colors.grey, width: 1.0), +// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), +// disabledBorder: OutlineInputBorder( +// borderSide: BorderSide(color: Colors.grey, width: 1.0), +// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), +// enabledBorder: OutlineInputBorder( +// borderSide: BorderSide(color: Colors.grey, width: 1.0), +// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0), +// ), +// ), +// ), +// )); +// } +// } diff --git a/lib/widgets/loadings/ShimmerLoading.dart b/lib/widgets/loadings/ShimmerLoading.dart index 64a31843..678c24cd 100644 --- a/lib/widgets/loadings/ShimmerLoading.dart +++ b/lib/widgets/loadings/ShimmerLoading.dart @@ -6,10 +6,10 @@ import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; class ShimmerLoadingWidget extends StatefulWidget { - Future Function() onPreProccess; - Widget Function() loadingWidget; - Widget Function() realWidget; - Function() onFinish; + Future Function()? onPreProccess; + Widget Function()? loadingWidget; + Widget Function()? realWidget; + Function()? onFinish; ShimmerLoadingWidget({this.onPreProccess, this.loadingWidget, this.realWidget, this.onFinish}); void loadWidget() {} @@ -23,15 +23,15 @@ class _ShimmerLoadingWidgetState extends State { @override Widget build(BuildContext context) { - Stream preProccess = (() async* { - await super.widget.onPreProccess(); + Stream preProccess = (() async* { + await super.widget.onPreProccess!(); })(); // TODO: implement build return StreamBuilder( stream: preProccess, builder: (context, snapshot) { - Widget widget; + Widget? widget; if (snapshot.hasError) { widget = Texts( "Error happened", @@ -46,16 +46,18 @@ class _ShimmerLoadingWidgetState extends State { case ConnectionState.active: break; case ConnectionState.waiting: - widget = Shimmer.fromColors(child: super.widget.loadingWidget(), baseColor: Colors.red, highlightColor: Colors.yellow); + widget = Shimmer.fromColors(child: super.widget.loadingWidget!(), baseColor: Colors.red, highlightColor: Colors.yellow); break; case ConnectionState.done: - widget = super.widget.realWidget(); - if (super.widget.onFinish != null) super.widget.onFinish(); + widget = super.widget.realWidget!(); + if (super.widget.onFinish != null) super.widget.onFinish!(); break; + default: + widget = SizedBox(); } } - return widget; + return widget!; }); } } diff --git a/lib/widgets/mobile-no/mobile_no.dart b/lib/widgets/mobile-no/mobile_no.dart index 5349a3e0..c8d3c7b1 100644 --- a/lib/widgets/mobile-no/mobile_no.dart +++ b/lib/widgets/mobile-no/mobile_no.dart @@ -9,10 +9,10 @@ import 'package:provider/provider.dart'; import '../../Constants.dart'; class PhoneNumberSelectorWidget extends StatefulWidget { - final Function onNumberChange; - final Function onCountryChange; - final String mobileNo; - PhoneNumberSelectorWidget({Key key, this.onNumberChange, this.onCountryChange, this.mobileNo}) : super(key: key); + final Function? onNumberChange; + final Function? onCountryChange; + final String? mobileNo; + PhoneNumberSelectorWidget({Key? key, this.onNumberChange, this.onCountryChange, this.mobileNo}) : super(key: key); @override _PhoneNumberSelectorWidgetState createState() { @@ -24,7 +24,7 @@ class _PhoneNumberSelectorWidgetState extends State { var _selectedType = '+966'; String countryCode = '966'; List counties = []; - ProjectViewModel projectProvider; + ProjectViewModel? projectProvider; @override void initState() { for (var element in countriesData) counties.add(Countries.fromJson(element)); @@ -43,7 +43,7 @@ class _PhoneNumberSelectorWidgetState extends State { String countryName = ""; for (var element in counties) { if (element.code == countryCode) { - countryName = projectProvider.isArabic == true ? element.nameAr : element.name; + countryName = projectProvider?.isArabic == true ? element.nameAr : element.name; } } @@ -56,7 +56,7 @@ class _PhoneNumberSelectorWidgetState extends State { ); } - Widget inputWidget(String _labelText, String _hintText, {String prefix, bool isEnable = true, bool hasSelection = false}) { + Widget inputWidget(String _labelText, String _hintText, {String? prefix, bool isEnable = true, bool hasSelection = false}) { return Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), alignment: Alignment.center, @@ -90,7 +90,7 @@ class _PhoneNumberSelectorWidgetState extends State { enabled: isEnable, scrollPadding: EdgeInsets.zero, keyboardType: TextInputType.number, - onChanged: (value) => widget.onNumberChange(value), + onChanged: (value) => widget.onNumberChange!(value), style: TextStyle( fontSize: 14, height: 21 / 14, @@ -135,14 +135,14 @@ class _PhoneNumberSelectorWidgetState extends State { ), itemBuilder: (_) => >[ if (hasSelection) - for (var country in counties) PopupMenuItem(child: Text(projectProvider.isArabic == true ? country.nameAr : country.name), value: country.code) + for (var country in counties) PopupMenuItem(child: Text(projectProvider!.isArabic == true ? country.nameAr : country.name), value: country.code) ], onSelected: (countryCode) { setState(() { this.countryCode = countryCode; _selectedType = countryCode; }); - widget.onCountryChange(countryCode); + widget.onCountryChange!(countryCode); }, )); } @@ -156,9 +156,9 @@ class MobileNo extends StatefulWidget { final double marginRight; final double marginBottom; final double marginLeft; - final TextEditingController controller; - final Function onNumberChange; - final Function onCountryChange; + final TextEditingController? controller; + final Function? onNumberChange; + final Function? onCountryChange; MobileNo({this.disabled = false, this.marginTop = 0, this.marginRight = 0, this.marginBottom = 0, this.controller, this.marginLeft = 0, this.onNumberChange, this.onCountryChange, this.margin = 0}); @@ -170,7 +170,7 @@ class _MobileNo extends State { var _selectedType = '+966'; String countryCode = '+966'; List counties = []; - ProjectViewModel projectProvider; + ProjectViewModel? projectProvider; @override void initState() { countriesData.forEach((element) { @@ -194,7 +194,7 @@ class _MobileNo extends State { decoration: BoxDecoration( color: Colors.white, border: Border.all( - color: Colors.grey[400], + color: Colors.grey[400]!, width: 1.0, ), borderRadius: BorderRadius.circular(10), @@ -209,16 +209,16 @@ class _MobileNo extends State { iconSize: 40, elevation: 16, onChanged: (value) => { - widget.onCountryChange(value), + widget.onCountryChange!(value), setState(() { - countryCode = value; - _selectedType = value; + countryCode = value!; + _selectedType = value!; }) }, items: counties.map>((Countries value) { return DropdownMenuItem( value: value.code, - child: Text(projectProvider.isArabic == true ? value.nameAr : value.name), + child: Text(projectProvider!.isArabic == true ? value.nameAr : value.name), ); }).toList()), ), @@ -263,7 +263,7 @@ class _MobileNo extends State { // onChanged: (value) { // widget.controller.text = countryCode; // }, - onChanged: (value) => widget.onNumberChange(value), + onChanged: (value) => widget.onNumberChange!(value), decoration: InputDecoration(counterText: "", border: InputBorder.none, hintText: '5xxxxxxxx'), ), diff --git a/lib/widgets/my_rich_text.dart b/lib/widgets/my_rich_text.dart index c3d108c5..6d183d3b 100644 --- a/lib/widgets/my_rich_text.dart +++ b/lib/widgets/my_rich_text.dart @@ -4,7 +4,7 @@ class MyRichText extends StatelessWidget { final String title; final String value; final bool isArabic; - MyRichText(this.title,this.value,this.isArabic,{Key key}) : super(key: key); + MyRichText(this.title,this.value,this.isArabic,{Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/widgets/new_design/doctor_header.dart b/lib/widgets/new_design/doctor_header.dart index 549c182a..cbd6dde2 100644 --- a/lib/widgets/new_design/doctor_header.dart +++ b/lib/widgets/new_design/doctor_header.dart @@ -10,9 +10,9 @@ import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_send_email_dialog.dart'; import 'package:diplomaticquarterapp/widgets/my_rich_text.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; class DoctorHeader extends StatelessWidget { final HeaderModel headerModel; @@ -20,23 +20,23 @@ class DoctorHeader extends StatelessWidget { final VoidCallback onRatingAndReviewTap; final bool showConfirmMessageDialog; final String buttonTitle; - final String buttonIcon; + final String? buttonIcon; final bool isNeedToShowButton; final bool isShowName; DoctorHeader( - {Key key, - @required this.headerModel, - @required this.buttonTitle, - @required this.onTap, + {Key? key, + required this.headerModel, + required this.buttonTitle, + required this.onTap, this.isNeedToShowButton = true, this.isShowName = false, this.buttonIcon, this.showConfirmMessageDialog = true, - @required this.onRatingAndReviewTap}) + required this.onRatingAndReviewTap}) : super(key: key); - ProjectViewModel projectViewModel; + late ProjectViewModel projectViewModel; @override Widget build(BuildContext context) { @@ -127,15 +127,25 @@ class DoctorHeader extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox(width: 21), - RatingBar.readOnly( - initialRating: headerModel.actualDoctorRate + 0.0, - size: 15.0, - filledColor: Color(0XFFD02127), - emptyColor: Color(0XFFD02127), - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star_border, + // RatingBar.readOnly( + // initialRating: headerModel.actualDoctorRate + 0.0, + // size: 15.0, + // filledColor: Color(0XFFD02127), + // emptyColor: Color(0XFFD02127), + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: Icons.star, + // emptyIcon: Icons.star_border, + // ), + RatingBar( + initialRating: headerModel.actualDoctorRate + 0.0, + //size: 15.0, + // filledColor: , + // emptyColor: , + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: , + ratingWidget: RatingWidget(full: Icon(Icons.star, color:Colors.yellow[700], size: 15,), half: Icon(Icons.star_half, color:Colors.grey[500], size: 15), empty: Icon(Icons.star_half, color:Colors.grey[500], size: 15)), onRatingUpdate: (double value) { }, ), SizedBox(width: 6), Text( @@ -200,7 +210,7 @@ class DoctorHeader extends StatelessWidget { void getDoctorRatingsDetails(context) { GifLoaderDialogUtils.showMyDialog(context); - List doctorDetailsList = List(); + List doctorDetailsList = []; DoctorsListService service = new DoctorsListService(); service.getDoctorsRatingDetails(headerModel.doctorId, context).then((res) { @@ -269,15 +279,27 @@ class DoctorHeader extends StatelessWidget { style: TextStyle(fontSize: 32.0, color: Colors.black, letterSpacing: -0.64, fontWeight: FontWeight.bold))), Container( margin: EdgeInsets.symmetric(horizontal: 20.0), - child: RatingBar.readOnly( - initialRating: this.headerModel.decimalDoctorRate != null ? double.tryParse(this.headerModel.decimalDoctorRate) : this.headerModel.actualDoctorRate.toDouble(), - size: 35.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + child: + + // RatingBar.readOnly( + // initialRating: this.headerModel.decimalDoctorRate != null ? double.tryParse(this.headerModel.decimalDoctorRate) : this.headerModel.actualDoctorRate.toDouble(), + // size: 35.0, + // filledColor: Colors.yellow[700], + // emptyColor: Colors.grey[500], + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: Icons.star, + // emptyIcon: Icons.star, + // ), + RatingBar( + initialRating: this.headerModel!.decimalDoctorRate! != null ? double.tryParse(this.headerModel!.decimalDoctorRate!)! : this.headerModel!.actualDoctorRate!.toDouble(), + //size: 15.0, + // filledColor: , + // emptyColor: , + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: , + ratingWidget: RatingWidget(full: Icon(Icons.star, color:Colors.yellow[700], size: 15,), half: Icon(Icons.star_half, color:Colors.grey[500], size: 15), empty: Icon(Icons.star_half, color:Colors.grey[500], size: 15)), onRatingUpdate: (double value) { }, ), ), ], @@ -298,7 +320,7 @@ class DoctorHeader extends StatelessWidget { width: 100.0, margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0), child: Text(TranslationBase.of(context).excellent, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))), - getRatingLine(doctorDetailsList[0].ratio, Colors.green[700]), + getRatingLine(doctorDetailsList[0].ratio, Colors.green[700]!), ], ), Container( @@ -407,7 +429,7 @@ class DoctorHeader extends StatelessWidget { barrierDismissible: true, barrierLabel: '', context: context, - pageBuilder: (context, animation1, animation2) {}); + pageBuilder: (context, animation1, animation2) => SizedBox()); } double getRatingWidth(double patientNumber) { diff --git a/lib/widgets/new_design/my_tab_view.dart b/lib/widgets/new_design/my_tab_view.dart index 74723a88..911f8da8 100644 --- a/lib/widgets/new_design/my_tab_view.dart +++ b/lib/widgets/new_design/my_tab_view.dart @@ -11,7 +11,7 @@ class MyTabView extends StatelessWidget { this.value, this.groupValue, this.onPressed, { - Key key, + Key? key, }) : super(key: key); @override diff --git a/lib/widgets/nfc/nfc_reader_sheet.dart b/lib/widgets/nfc/nfc_reader_sheet.dart index 8881cb29..a52874e9 100644 --- a/lib/widgets/nfc/nfc_reader_sheet.dart +++ b/lib/widgets/nfc/nfc_reader_sheet.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_nfc_kit/flutter_nfc_kit.dart'; import 'package:flutter_svg/flutter_svg.dart'; -void showNfcReader(BuildContext context, {Function onNcfScan, VoidCallback onCancel}) { +void showNfcReader(BuildContext context, {required Function onNcfScan, required VoidCallback onCancel}) { showModalBottomSheet( context: context, enableDrag: false, @@ -23,8 +23,8 @@ void showNfcReader(BuildContext context, {Function onNcfScan, VoidCallback onCan } class NfcLayout extends StatefulWidget { - Function onNcfScan; - VoidCallback onCancel; + Function? onNcfScan; + VoidCallback? onCancel; NfcLayout({this.onNcfScan, this.onCancel}); @@ -34,8 +34,8 @@ class NfcLayout extends StatefulWidget { class _NfcLayoutState extends State { bool _reading = false; - Widget mainWidget; - String nfcId; + late Widget mainWidget; + late String nfcId; @override void initState() { @@ -52,7 +52,7 @@ class _NfcLayoutState extends State { }); Future.delayed(const Duration(milliseconds: 500), () async { await FlutterNfcKit.finish(); - widget.onNcfScan(nfcId); + widget.onNcfScan!(nfcId); Navigator.pop(context); }); nfcId = value.id; @@ -114,7 +114,7 @@ class _NfcLayoutState extends State { child: CustomTextButton( elevation: 0, onPressed: () { - widget.onCancel(); + widget.onCancel!(); Navigator.pop(context); }, child: Text("CANCEL"), diff --git a/lib/widgets/offers_packages/PackagesCartItemCard.dart b/lib/widgets/offers_packages/PackagesCartItemCard.dart index d53f9505..014fcd19 100644 --- a/lib/widgets/offers_packages/PackagesCartItemCard.dart +++ b/lib/widgets/offers_packages/PackagesCartItemCard.dart @@ -16,9 +16,9 @@ class PackagesCartItemCard extends StatefulWidget { final PackagesCartItemsResponseModel itemModel; final StepperCallbackFuture shouldStepperChangeApply; final PackagesViewModel viewModel; - final Function getCartItems; + final Function? getCartItems; - const PackagesCartItemCard({@required this.itemModel, @required this.shouldStepperChangeApply, @required this.viewModel, this.getCartItems, Key key}) : super(key: key); + const PackagesCartItemCard({required this.itemModel, required this.shouldStepperChangeApply, required this.viewModel, this.getCartItems, Key? key}) : super(key: key); @override State createState() => PackagesCartItemCardState(); @@ -51,7 +51,7 @@ class PackagesCartItemCardState extends State { InkWell( onTap: () async { await widget.viewModel.service.deleteProductFromCart(widget.itemModel.id, context: context, showLoading: false); - widget.getCartItems(); + widget.getCartItems!(); }, child: Padding( padding: const EdgeInsets.only(right: 3, bottom: 3), @@ -112,7 +112,7 @@ Widget _itemDescription(String desc) => Text( ), ); -Widget _itemPrice(double price, {@required BuildContext context}) { +Widget _itemPrice(double price, {required BuildContext context}) { final prc = (price ?? 0.0).toStringAsFixed(2); return Text( '$prc ${TranslationBase.of(context).sar}', diff --git a/lib/widgets/offers_packages/PackagesOfferCard.dart b/lib/widgets/offers_packages/PackagesOfferCard.dart index f0f7938c..72f6802f 100644 --- a/lib/widgets/offers_packages/PackagesOfferCard.dart +++ b/lib/widgets/offers_packages/PackagesOfferCard.dart @@ -5,19 +5,19 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:rating_bar/rating_bar.dart'; bool wide = true; class PackagesItemCard extends StatefulWidget { - final double itemWidth; - final double itemHeight; - final double itemContentPadding; + final double? itemWidth; + final double? itemHeight; + final double? itemContentPadding; final PackagesResponseModel itemModel; final Function(PackagesResponseModel product) onCartClick; - const PackagesItemCard({this.itemWidth, this.itemHeight, @required this.itemModel, @required this.itemContentPadding, @required this.onCartClick, Key key}) : super(key: key); + const PackagesItemCard({this.itemWidth, this.itemHeight, required this.itemModel, required this.itemContentPadding, required this.onCartClick, Key? key}) : super(key: key); @override State createState() => PackagesItemCardState(); @@ -99,16 +99,18 @@ class PackagesItemCardState extends State { style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.bold, color: Color(0xff2B353E), letterSpacing: -0.48), ), ), - RatingBar.readOnly( + RatingBar( initialRating: 4.5, // todo ask haroon about parameter for rating - size: 18.0, - filledColor: Color(0XFFD02127), - emptyColor: Color(0XFFD02127), - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star_border, - ), + // size: 18.0, + // filledColor: Color(0XFFD02127), + // emptyColor: Color(0XFFD02127), + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: Icons.star, + // emptyIcon: , + // + ratingWidget: RatingWidget( full:Icon(Icons.star, color:Color(0XFFD02127)), half:Icon(Icons.star_half, color: Color(0XFFD02127)), empty: Icon(Icons.star_border,color: Color(0XFFD02127)) , + ), onRatingUpdate: (double value) { }), ], ), if(widget.onCartClick != null) @@ -166,16 +168,16 @@ class PackagesItemCardState extends State { margin: const EdgeInsets.only(top: 0.0), child: Text(widget.itemModel.price.toString().trim() + " " + TranslationBase.of(context).sar, style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.bold, letterSpacing: -0.56))), - RatingBar.readOnly( - initialRating: 4.5, - size: 18.0, - filledColor: Color(0XFFD02127), - emptyColor: Color(0XFFD02127), - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star_border, - ), + // RatingBar.readOnly( + // initialRating: 4.5, + // size: 18.0, + // filledColor: Color(0XFFD02127), + // emptyColor: Color(0XFFD02127), + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: Icons.star, + // emptyIcon: Icons.star_border, + // ), ], ), InkWell( diff --git a/lib/widgets/offers_packages/PackagesOrderHistoryItemCard.dart b/lib/widgets/offers_packages/PackagesOrderHistoryItemCard.dart index 6ba6bb29..a12ea9b3 100644 --- a/lib/widgets/offers_packages/PackagesOrderHistoryItemCard.dart +++ b/lib/widgets/offers_packages/PackagesOrderHistoryItemCard.dart @@ -15,9 +15,9 @@ bool wide = true; class PackagesOrderHistoryItemCard extends StatefulWidget { final PackagesResponseModel itemModel; final PackagesViewModel viewModel; - final Function getCartItems; + final Function? getCartItems; - const PackagesOrderHistoryItemCard({@required this.itemModel, @required this.viewModel, this.getCartItems, Key key}) : super(key: key); + const PackagesOrderHistoryItemCard({required this.itemModel, required this.viewModel, this.getCartItems, Key? key}) : super(key: key); @override State createState() => PackagesOrderHistoryItemCardState(); @@ -59,7 +59,7 @@ class PackagesOrderHistoryItemCardState extends State InkWell( +Widget _cancelButton(BuildContext context, {required PackagesResponseModel itemModel, VoidCallback? onClick}) => InkWell( onTap:onClick, child: Padding( padding: const EdgeInsets.only(right: 3, bottom: 3), @@ -110,7 +110,7 @@ Widget _itemDescription(String desc) => Text( ), ); -Widget _itemPrice(double price, {@required BuildContext context}) { +Widget _itemPrice(double price, {required BuildContext context}) { final prc = (price ?? 0.0).toStringAsFixed(2); return Text( '$prc ${TranslationBase.of(context).sar}', diff --git a/lib/widgets/offers_packages/offers_packages.dart b/lib/widgets/offers_packages/offers_packages.dart index 89d395fa..e131d177 100644 --- a/lib/widgets/offers_packages/offers_packages.dart +++ b/lib/widgets/offers_packages/offers_packages.dart @@ -128,7 +128,7 @@ class _OffersAndPackagesWidgetState extends State { // - - - - - - - - - - - - - - class OfferPackagesItemWidget extends StatefulWidget { final OfferPackagesItemModel model; - OfferPackagesItemWidget({@required this.model}); + OfferPackagesItemWidget({required this.model}); @override State createState() { @@ -247,7 +247,7 @@ class OfferPackagesItemModel { OfferPackagesItemModel(this.bannerUrl, this.title, this.desc, this.item, this.action); static List dummy() { - List list = List(); + List list = []; list.add(OfferPackagesItemModel( "http://blog.naseej.com/hs-fs/hubfs/ellucian-banner-9.jpg?width=1486&height=782&name=ellucian-banner-9.jpg", "Sample Title", diff --git a/lib/widgets/others/OrderLogItem.dart b/lib/widgets/others/OrderLogItem.dart index 3e8305d3..ec93f0de 100644 --- a/lib/widgets/others/OrderLogItem.dart +++ b/lib/widgets/others/OrderLogItem.dart @@ -3,8 +3,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class OrderLogItem extends StatelessWidget { - final String title; - final String value; + final String? title; + final String? value; OrderLogItem({ this.title, this.value}); @override Widget build(BuildContext context) { @@ -22,7 +22,7 @@ class OrderLogItem extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(title,color: Colors.grey,), + Texts(title!,color: Colors.grey,), SizedBox(height: 4,), Texts(value??''), ], diff --git a/lib/widgets/others/StarRating.dart b/lib/widgets/others/StarRating.dart index 54ad3162..78e84369 100644 --- a/lib/widgets/others/StarRating.dart +++ b/lib/widgets/others/StarRating.dart @@ -8,7 +8,7 @@ class StarRating extends StatelessWidget { final int totalCount; final bool forceStars; - StarRating({Key key, this.totalAverage: 0.0, this.size: 16.0, this.totalCount=5, this.forceStars = false}) : super(key: key); + StarRating({Key? key, this.totalAverage= 0.0, this.size= 16.0, this.totalCount=5, this.forceStars = false}) : super(key: key); @override Widget build(BuildContext context) { @@ -31,7 +31,7 @@ class StarRating extends StatelessWidget { if (totalCount!=null) SizedBox(width: 5.0), if (totalCount!=null) - Texts("("+totalCount.toString()+")", style: "overline", color: Colors.grey[400],) + Texts("("+totalCount.toString()+")", style: "overline", color: Colors.grey[400]!,) ] ); } diff --git a/lib/widgets/others/app_expandable_notifier.dart b/lib/widgets/others/app_expandable_notifier.dart index ece72712..aa0566b0 100644 --- a/lib/widgets/others/app_expandable_notifier.dart +++ b/lib/widgets/others/app_expandable_notifier.dart @@ -12,10 +12,10 @@ import 'package:provider/provider.dart'; /// [title] the widget title /// [collapsed] The widget shown in the collapsed state class AppExpandableNotifier extends StatefulWidget { - final Widget headerWidget; - final Widget bodyWidget; - final String title; - final Widget collapsed; + final Widget? headerWidget; + final Widget? bodyWidget; + final String? title; + final Widget? collapsed; final bool isExpand; bool expandFlag = false; bool hasCounter = false; @@ -29,7 +29,7 @@ class AppExpandableNotifier extends StatefulWidget { } class _AppExpandableNotifier extends State { - ProjectViewModel projectViewModel; + late ProjectViewModel projectViewModel; @override void initState() { @@ -70,7 +70,7 @@ class _AppExpandableNotifier extends State { scrollOnExpand: true, scrollOnCollapse: false, child: ExpandablePanel( - hasIcon: false, + // hasIcon: false, theme: const ExpandableThemeData( headerAlignment: ExpandablePanelHeaderAlignment.center, tapBodyToCollapse: true, @@ -139,7 +139,7 @@ class _AppExpandableNotifier extends State { ), ), collapsed: widget.collapsed ?? Container(), - expanded: widget.bodyWidget, + expanded: widget.bodyWidget!, builder: (_, collapsed, expanded) { return Expandable( controller: widget.controller, diff --git a/lib/widgets/others/app_scaffold_pharmacy_widget.dart b/lib/widgets/others/app_scaffold_pharmacy_widget.dart index 0d44ec26..ec45fbfb 100644 --- a/lib/widgets/others/app_scaffold_pharmacy_widget.dart +++ b/lib/widgets/others/app_scaffold_pharmacy_widget.dart @@ -14,23 +14,23 @@ import 'not_auh_page.dart'; class PharmacyAppScaffold extends StatelessWidget { final String appBarTitle; final Widget body; - final Widget bottomSheet; + final Widget? bottomSheet; final bool isLoading; final bool isShowAppBar; - final bool hasAppBarParam; - final BaseViewModel baseViewModel; - final bool isBottomBar; - final Widget floatingActionButton; - final String title; - final String description; + final bool? hasAppBarParam; + final BaseViewModel? baseViewModel; + final bool? isBottomBar; + final Widget? floatingActionButton; + final String? title; + final String? description; final bool isShowDecPage; - final Color backgroundColor; + final Color? backgroundColor; AuthenticatedUserObject authenticatedUserObject = locator(); PharmacyAppScaffold( - {@required this.body, + {required this.body, this.appBarTitle = '', this.isLoading = false, this.isShowAppBar = false, @@ -55,10 +55,10 @@ class PharmacyAppScaffold extends StatelessWidget { ? AppBar( elevation: 0, backgroundColor: Color(0xff5AB145), - textTheme: TextTheme( - headline6: - TextStyle(color: Colors.white, fontWeight: FontWeight.bold), - ), + // textTheme: TextTheme( + // headline6: + // TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + // ), title: Text(authenticatedUserObject.isLogin ? appBarTitle.toUpperCase() : appBarTitle.toUpperCase()), @@ -74,7 +74,7 @@ class PharmacyAppScaffold extends StatelessWidget { body: (!authenticatedUserObject.isLogin && isShowDecPage) ? NotAutPage( title: appBarTitle, - description: description, + description: description!, ) : baseViewModel != null ? NetworkBaseView( diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 6865ece5..3fb690f2 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:badges/badges.dart'; +import 'package:badges/badges.dart' as badge_import; import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; @@ -39,49 +39,49 @@ import 'floating_button_search.dart'; import 'network_base_view.dart'; import 'not_auh_page.dart'; -VoidCallback _onCartClick; +VoidCallback? _onCartClick; class AppScaffold extends StatefulWidget { final String appBarTitle; final Widget body; - final Widget bottomSheet; - final Widget bottomNavigationBar; + final Widget? bottomSheet; + final Widget? bottomNavigationBar; final bool isLoading; final bool isShowAppBar; final bool showNewAppBar; final bool showNewAppBarTitle; - final bool hasAppBarParam; - final BaseViewModel baseViewModel; + final bool? hasAppBarParam; + final BaseViewModel? baseViewModel; final bool isBottomBar; - final Widget floatingActionButton; + final Widget? floatingActionButton; final bool isPharmacy; final bool isOfferPackages; final bool showPharmacyCart; final bool showOfferPackagesCart; - final String title; - final String description; + final String? title; + final String? description; final bool isShowDecPage; - final List infoList; - final Color backgroundColor; + final List? infoList; + final Color? backgroundColor; final double preferredSize; final bool showHomeAppBarIcon; - final List appBarIcons; - final List imagesInfo; + final List? appBarIcons; + final List? imagesInfo; final bool isHelp; final bool isLocalLoader; - final Function backButtonTab; - final String icon; + final VoidCallbackAction? backButtonTab; + final String? icon; final bool showDropDown; - final int dropdownIndexValue; - List dropDownList; - final Function(int) dropDownIndexChange; - Function onTap; + final int? dropdownIndexValue; + List? dropDownList; + final void Function(int?)? dropDownIndexChange; + VoidCallbackAction? onTap; final bool isMainPharmacyPages; final bool extendBody; - final ValueChanged changeCurrentTab; - final int currentTab; + final ValueChanged? changeCurrentTab; + final int? currentTab; final bool isShowPharmacyAppbar; - final Widget customAppBar; + final Widget? customAppBar; AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -89,7 +89,7 @@ class AppScaffold extends StatefulWidget { } AppScaffold( - {@required this.body, + {required this.body, this.appBarTitle = '', this.isLoading = false, this.isShowAppBar = false, @@ -137,7 +137,7 @@ class AppScaffold extends StatefulWidget { class _AppScaffoldState extends State { AuthenticatedUserObject authenticatedUserObject = locator(); - AppBarWidget appBar; + late AppBarWidget appBar; @override void initState() { @@ -216,6 +216,8 @@ class _AppScaffoldState extends State { PharmacyPagesViewModel pagesViewModel = Provider.of(context); bool isUserNotLogin = (!Provider.of(context, listen: false).isLogin && widget.isShowDecPage); + + return Scaffold( backgroundColor: widget.backgroundColor ?? CustomColors.appBackgroudGrey2Color, @@ -225,34 +227,40 @@ class _AppScaffoldState extends State { // ? widget.customAppBar != null // ? widget.customAppBar - appBar: isUserNotLogin + appBar: isUserNotLogin! ? null - : widget.isShowPharmacyAppbar - ? pharmacyAppbar() - : (widget.showNewAppBar - ? NewAppBarWidget( - title: widget.appBarTitle, - showTitle: widget.showNewAppBarTitle, - showDropDown: widget.showDropDown, - dropdownIndexValue: widget.dropdownIndexValue, - dropDownList: widget.dropDownList ?? [], + : widget.isShowPharmacyAppbar! + ? PreferredSize( + preferredSize: Size.fromHeight(70), + child: pharmacyAppbar()!) + : (widget.showNewAppBar! + ? PreferredSize( + preferredSize: Size.fromHeight(70), + child: NewAppBarWidget( + title: widget.appBarTitle!, + showTitle: widget.showNewAppBarTitle!, + showDropDown: widget.showDropDown!, + dropdownIndexValue: widget.dropdownIndexValue!, + dropDownList: widget.dropDownList! ?? [], dropDownIndexChange: widget.dropDownIndexChange, - appBarIcons: widget.appBarIcons, - onTap: widget.onTap, - ) - : (widget.isShowAppBar + appBarIcons: widget.appBarIcons!, + onTap: widget.onTap!, + )) + : (widget.isShowAppBar! ? widget.customAppBar != null - ? widget.customAppBar + ? PreferredSize( + preferredSize: Size.fromHeight(70), + child: widget.customAppBar!) : appBar = AppBarWidget( - appBarTitle: widget.appBarTitle, - appBarIcons: widget.appBarIcons, - showHomeAppBarIcon: widget.showHomeAppBarIcon, - isPharmacy: widget.isPharmacy, - showPharmacyCart: widget.showPharmacyCart, - isOfferPackages: widget.isOfferPackages, - showOfferPackagesCart: widget.showOfferPackagesCart, - isShowDecPage: widget.isShowDecPage, - backButtonTab: widget.backButtonTab, + appBarTitle: widget.appBarTitle!, + appBarIcons: widget.appBarIcons!, + showHomeAppBarIcon: widget.showHomeAppBarIcon!, + isPharmacy: widget.isPharmacy!, + showPharmacyCart: widget.showPharmacyCart!, + isOfferPackages: widget.isOfferPackages!, + showOfferPackagesCart: widget.showOfferPackagesCart!, + isShowDecPage: widget.isShowDecPage!, + backButtonTab: widget.backButtonTab!, ) : null)), bottomSheet: widget.bottomSheet, @@ -262,7 +270,7 @@ class _AppScaffoldState extends State { child: isUserNotLogin ? NotAutPage( title: widget.title ?? widget.appBarTitle, - description: widget.description, + description: widget.description!, infoList: widget.infoList, imagesInfo: widget.imagesInfo, icon: widget.icon, @@ -277,27 +285,31 @@ class _AppScaffoldState extends State { bottomNavigationBar: widget.isBottomBar ? BottomNavPharmacyBar( changeIndex: changeCurrentTab, - index: widget.currentTab, + index: widget.currentTab!, ) : null, floatingActionButton: widget.floatingActionButton, ); + } + @override + Size get preferredSize => const Size.fromHeight(kToolbarHeight); + void changeCurrentTab(int value) { if (widget.isMainPharmacyPages) { - widget.changeCurrentTab(value); + widget.changeCurrentTab!(value); } else { Navigator.pushAndRemoveUntil( - locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: value)), (Route r) => false); + locator().navigatorKey!.currentContext!, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: value)), (Route r) => false); } } void _scanQrAndGetProduct() async { try { - String result = (await BarcodeScanner.scan())?.rawContent; + String? result = (await BarcodeScanner.scan())?.rawContent!; try { - String barcode = result; + String barcode = result!; GifLoaderDialogUtils.showMyDialog(context); await BaseAppClient().getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", onSuccess: (dynamic response, int statusCode) { print(response); @@ -323,17 +335,17 @@ class _AppScaffoldState extends State { } } -class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { +class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { final bool showTitle; final String title; - final bool showDropDown; - final int dropdownIndexValue; - List dropDownList; - final Function(int) dropDownIndexChange; - final List appBarIcons; - Function onTap; - - NewAppBarWidget({Key key, this.showTitle = false, this.showDropDown = false, this.title = "", this.dropDownList, this.appBarIcons, this.dropdownIndexValue, this.dropDownIndexChange, this.onTap}) + final bool? showDropDown; + final int? dropdownIndexValue; + List? dropDownList; + final void Function(int?)? dropDownIndexChange; + final List? appBarIcons; + VoidCallbackAction? onTap; + + NewAppBarWidget({Key? key, this.showTitle = false, this.showDropDown = false, this.title = "", this.dropDownList, this.appBarIcons, this.dropdownIndexValue, this.dropDownIndexChange, this.onTap}) : super(key: key); @override @@ -346,7 +358,7 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { // backgroundColor: Colors.red, // automaticallyImplyLeading: false, leading: ArrowBack( - onTap: onTap, + onTap: onTap!, ), titleSpacing: -8, // centerTitle: false, @@ -361,7 +373,7 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { fontSize: 24, fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 35 / 24), ), ), - if (showDropDown) + if (showDropDown!) Container( decoration: containerRadius(Color(0xFFF7F7F7), 30), height: 30, @@ -374,11 +386,11 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { dropdownColor: CustomColors.lightGreyColor, value: dropdownIndexValue, items: [ - for (int i = 0; i < dropDownList.length; i++) + for (int i = 0; i < dropDownList!.length; i++) DropdownMenuItem( value: i, child: AutoSizeText( - dropDownList[i], + dropDownList![i], style: TextStyle( fontSize: 12, fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), @@ -402,7 +414,7 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { ), actions: [ if (appBarIcons != null) - ...appBarIcons + ...appBarIcons! else IconButton( onPressed: () { @@ -423,20 +435,20 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { Size get preferredSize => Size(double.maxFinite, 60); } -class AppBarWidget extends StatefulWidget with PreferredSizeWidget { +class AppBarWidget extends StatefulWidget implements PreferredSizeWidget { final AuthenticatedUserObject authenticatedUserObject = locator(); - final String appBarTitle; - final bool showHomeAppBarIcon; - final List appBarIcons; + final String? appBarTitle; + final bool? showHomeAppBarIcon; + final List? appBarIcons; final bool isPharmacy; final bool isOfferPackages; final bool showPharmacyCart; final bool showOfferPackagesCart; final bool isShowDecPage; - final Function backButtonTab; - Function(String) badgeUpdater; + final VoidCallbackAction? backButtonTab; + Function(String)? badgeUpdater; AppBarWidget( {this.appBarTitle, @@ -477,12 +489,12 @@ class AppBarWidgetState extends State { return AppBar( elevation: 0, - backgroundColor: widget.isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color, - textTheme: TextTheme( - headline6: TextStyle(color: Theme.of(context).textTheme.headline1.color, fontWeight: FontWeight.bold), - ), - title: Text(widget.authenticatedUserObject.isLogin || !widget.isShowDecPage ? widget.appBarTitle.toUpperCase() : TranslationBase.of(context).serviceInformationTitle, - style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), + backgroundColor: widget.isPharmacy ? Colors.green : Theme.of(context).appBarTheme.backgroundColor, + // textTheme: TextTheme( + // headline6: TextStyle(color: Theme.of(context).textTheme.headline1.color, fontWeight: FontWeight.bold), + // ), + title: Text(widget.authenticatedUserObject.isLogin || !widget.isShowDecPage ? widget.appBarTitle!.toUpperCase() : TranslationBase.of(context).serviceInformationTitle, + style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1!.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), leading: Builder( builder: (BuildContext context) { return ArrowBack( @@ -494,7 +506,7 @@ class AppBarWidgetState extends State { actions: [ (widget.isPharmacy && widget.showPharmacyCart) ? IconButton( - icon: Badge( + icon: badge_import.Badge( badgeContent: Text( orderPreviewViewModel.cartResponse.quantityCount.toString(), style: TextStyle(color: Colors.white), @@ -507,8 +519,8 @@ class AppBarWidgetState extends State { : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) ? IconButton( - icon: Badge( - position: BadgePosition.topStart(top: -15, start: -10), + icon: badge_import.Badge( + position: badge_import.BadgePosition.topStart(top: -15, start: -10), badgeContent: Text( _badgeText, style: TextStyle(fontSize: 9, color: Colors.white, fontWeight: FontWeight.normal), @@ -517,10 +529,10 @@ class AppBarWidgetState extends State { color: Colors.white, onPressed: () { // Cart Click Event - if (_onCartClick != null) _onCartClick(); + if (_onCartClick != null) _onCartClick!(); }) : Container(), - if (widget.showHomeAppBarIcon) + if (widget.showHomeAppBarIcon!) IconButton( icon: Icon(FontAwesomeIcons.home), color: Colors.white, @@ -528,10 +540,10 @@ class AppBarWidgetState extends State { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); // Cart Click Event - if (_onCartClick != null) _onCartClick(); + if (_onCartClick != null) _onCartClick!(); }, ), - if (widget.appBarIcons != null) ...widget.appBarIcons + if (widget.appBarIcons != null) ...widget.appBarIcons! ], ); } diff --git a/lib/widgets/others/arrow_back.dart b/lib/widgets/others/arrow_back.dart index ebdd4877..ac0258a5 100644 --- a/lib/widgets/others/arrow_back.dart +++ b/lib/widgets/others/arrow_back.dart @@ -3,9 +3,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class ArrowBack extends StatelessWidget { - final Function onTap; + final VoidCallbackAction? onTap; - ArrowBack({Key key, this.onTap,}) : super(key: key); + ArrowBack({Key? key, this.onTap,}) : super(key: key); @override Widget build(BuildContext context) { @@ -13,7 +13,7 @@ class ArrowBack extends StatelessWidget { return GestureDetector( behavior: HitTestBehavior.opaque, onTap: Feedback.wrapForTap(() { - onTap != null ? onTap() : Navigator.maybePop(context); + onTap != null ? onTap! : Navigator.maybePop(context); }, context), child: Icon( Icons.arrow_back_ios, diff --git a/lib/widgets/others/bottom_bar.dart b/lib/widgets/others/bottom_bar.dart index a21eb817..dff0e1da 100644 --- a/lib/widgets/others/bottom_bar.dart +++ b/lib/widgets/others/bottom_bar.dart @@ -50,7 +50,7 @@ class _SearchBot extends State { // final SpeechToText speech = SpeechToText(); String error = ''; String _currentLocaleId = ""; - String lastError; + String? lastError; double level = 0.0; double minSoundLevel = 50000; @@ -60,7 +60,7 @@ class _SearchBot extends State { var selectedLang; bool isSearching = false; Map results = {}; - String lastStatus; + String? lastStatus; bool _isInit = true; TextEditingController searchController = TextEditingController(); @@ -98,8 +98,8 @@ class _SearchBot extends State { }); // await flutterTts.speak("Hello!"); //Future.delayed(const Duration(seconds: 1), () { - // initSpeechState() - // .then((value) => startVoiceSearch()); + initSpeechState() + .then((value) => startVoiceSearch()); //}); }, )), @@ -111,17 +111,17 @@ class _SearchBot extends State { ); } - // startVoiceSearch() async { - // speech.listen( - // onResult: resultListener, - // listenFor: Duration(seconds: 10), - // localeId: _currentLocaleId, - // onSoundLevelChange: soundLevelListener, - // cancelOnError: true, - // partialResults: true, - // onDevice: true, - // listenMode: ListenMode.confirmation); - // } + startVoiceSearch() async { + // speech.listen( + // onResult: resultListener, + // listenFor: Duration(seconds: 10), + // localeId: _currentLocaleId, + // onSoundLevelChange: soundLevelListener, + // cancelOnError: true, + // partialResults: true, + // onDevice: true, + // listenMode: ListenMode.confirmation); + } // void resultListener(SpeechRecognitionResult result) { // // lastWords = "${result.recognizedWords} - ${result.finalResult}"; @@ -161,17 +161,17 @@ class _SearchBot extends State { ].request(); } - // Future initSpeechState() async { - // await speech.initialize(onError: errorListener, onStatus: statusListener); - // - // _currentLocaleId = - // TranslationBase.of(AppGlobal.context).locale.languageCode == 'en' - // ? 'en-GB' - // : 'ar-SA'; // systemLocale.localeId; - // flutterTts.setLanguage(_currentLocaleId); - // - // // if (!mounted) return; - // } + Future initSpeechState() async { + // await speech.initialize(onError: errorListener, onStatus: statusListener); + + _currentLocaleId = + TranslationBase.of(AppGlobal.context).locale.languageCode == 'en' + ? 'en-GB' + : 'ar-SA'; // systemLocale.localeId; + flutterTts.setLanguage(_currentLocaleId); + + // if (!mounted) return; + } // void errorListener(SpeechRecognitionError error) { // //setState(() { diff --git a/lib/widgets/others/card_with_bg_widget.dart b/lib/widgets/others/card_with_bg_widget.dart index f21063b9..e31d3f27 100644 --- a/lib/widgets/others/card_with_bg_widget.dart +++ b/lib/widgets/others/card_with_bg_widget.dart @@ -13,7 +13,7 @@ import 'package:provider/provider.dart'; class CardWithBgWidget extends StatelessWidget { final Widget child; - CardWithBgWidget({@required this.child}); + CardWithBgWidget({required this.child}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/others/close_back.dart b/lib/widgets/others/close_back.dart index 804e1d00..44a49d4b 100644 --- a/lib/widgets/others/close_back.dart +++ b/lib/widgets/others/close_back.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; class CloseBack extends StatelessWidget{ - final Function onTap; + final VoidCallbackAction? onTap; - CloseBack({Key key, + CloseBack({Key? key, this.onTap }) : super(key: key); @@ -13,7 +13,7 @@ class CloseBack extends StatelessWidget{ return GestureDetector( behavior: HitTestBehavior.opaque, onTap: Feedback.wrapForTap(() { - onTap!=null ? onTap() : Navigator.pop(context); + onTap!=null ? onTap! : Navigator.pop(context); }, context), child: Icon(Icons.close, color: Colors.white), ); diff --git a/lib/widgets/others/entity_checkbox_list.dart b/lib/widgets/others/entity_checkbox_list.dart index 0a34778f..1716c8c3 100644 --- a/lib/widgets/others/entity_checkbox_list.dart +++ b/lib/widgets/others/entity_checkbox_list.dart @@ -7,17 +7,17 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class ProcedureListWidget extends StatefulWidget { - final PharmacyCategoriseViewModel model; - final Function addSelectedHistories; - final Function(CategoriseParentModel) removeHistory; - final Function(CategoriseParentModel) addHistory; - final Function(CategoriseParentModel) addRemarks; + final PharmacyCategoriseViewModel? model; + final VoidCallbackAction? addSelectedHistories; + final Function(CategoriseParentModel)? removeHistory; + final Function(CategoriseParentModel)? addHistory; + final Function(CategoriseParentModel)? addRemarks; - final bool Function(CategoriseParentModel) isEntityListSelected; - final List masterList; + final bool Function(CategoriseParentModel)? isEntityListSelected; + final List? masterList; ProcedureListWidget( - {Key key, + {Key? key, this.model, this.addSelectedHistories, this.removeHistory, @@ -33,8 +33,8 @@ class ProcedureListWidget extends StatefulWidget { class _ProcedureListWidgetState extends State { int selectedType = 0; - int typeUrgent; - int typeRegular; + late int typeUrgent; + late int typeRegular; setSelectedType(int val) { setState(() { @@ -42,13 +42,13 @@ class _ProcedureListWidgetState extends State { }); } - List items = List(); - List remarksList = List(); - List typeList = List(); + List items = []; + List remarksList =[]; + List typeList = []; @override void initState() { - items.addAll(widget.masterList); + items.addAll(widget.masterList!); super.initState(); } @@ -89,10 +89,10 @@ class _ProcedureListWidgetState extends State { Row( children: [ Checkbox( - value: widget.isEntityListSelected( + value: widget.isEntityListSelected!( historyInfo), activeColor: Colors.red[800], - onChanged: (bool newValue) { + onChanged: (bool? newValue) { selectOption(historyInfo); }), @@ -143,21 +143,21 @@ class _ProcedureListWidgetState extends State { selectOption(historyInfo){ setState(() { - if (widget.isEntityListSelected( + if (widget.isEntityListSelected!( historyInfo)) { widget - .removeHistory(historyInfo); + .removeHistory!(historyInfo); } else { - widget.addHistory(historyInfo); + widget.addHistory!(historyInfo); } }); } void filterSearchResults(String query) { - List dummySearchList = List(); - dummySearchList.addAll(widget.masterList); + List dummySearchList = []; + dummySearchList.addAll(widget.masterList!); if (query.isNotEmpty) { - List dummyListData = List(); + List dummyListData = []; dummySearchList.forEach((item) { if (item.name.toLowerCase().contains(query.toLowerCase())) { dummyListData.add(item); @@ -171,7 +171,7 @@ class _ProcedureListWidgetState extends State { } else { setState(() { items.clear(); - items.addAll(widget.masterList); + items.addAll(widget.masterList!); }); } } diff --git a/lib/widgets/others/floating_button_search.dart b/lib/widgets/others/floating_button_search.dart index 8e5c16b5..d3bc3156 100644 --- a/lib/widgets/others/floating_button_search.dart +++ b/lib/widgets/others/floating_button_search.dart @@ -88,7 +88,7 @@ class _FloatingSearchButton extends State with TickerProvi FlutterTts tts = FlutterTts(); String error = ''; String _currentLocaleId = ""; - String lastError; + late String lastError; double level = 0.0; var searchText; double minSoundLevel = 50000; @@ -97,18 +97,18 @@ class _FloatingSearchButton extends State with TickerProvi var selectedLang; bool isSearching = false; Map results = {}; - String lastStatus; - AuthenticatedUser user; + late String lastStatus; + late AuthenticatedUser? user; bool _isInit = true; var event = RobotProvider(); var sharedPref = new AppSharedPreferences(); bool _hasSpeech = false; - ProjectViewModel projectProvider; + late ProjectViewModel projectProvider; bool isAnimationEnable = true; - AnimationController controller; - Animation offset; - String networkImage; - bool isArabic; + late AnimationController controller; + late Animation offset; + String? networkImage; + late bool isArabic; @override void initState() { @@ -186,7 +186,7 @@ class _FloatingSearchButton extends State with TickerProvi child: Container( child: networkImage != null ? CachedNetworkImage( - imageUrl: networkImage, + imageUrl: networkImage!, placeholder: (context, url) => Image.asset('assets/images/gif/robot-idle.gif'), errorWidget: (context, url, error) => Icon(Icons.error), ) @@ -932,7 +932,7 @@ class RoboSearch { static var dialog; RoboSearch({ - @required this.context, + required this.context, }); showAlertDialog(BuildContext context) { @@ -959,7 +959,7 @@ typedef Disposer = void Function(); class MyStatefulBuilder extends StatefulWidget { const MyStatefulBuilder({ // @required this.builder, - @required this.dispose, + required this.dispose, }); //final StatefulWidgetBuilder builder; @@ -972,7 +972,7 @@ class MyStatefulBuilder extends StatefulWidget { class _MyStatefulBuilderState extends State { var event = RobotProvider(); var searchText; - static StreamSubscription streamSubscription; + static StreamSubscription? streamSubscription; static var isClosed = false; // stt.SpeechToText speech = stt.SpeechToText(); diff --git a/lib/widgets/others/network_base_view.dart b/lib/widgets/others/network_base_view.dart index 7eacbd35..cea174ea 100644 --- a/lib/widgets/others/network_base_view.dart +++ b/lib/widgets/others/network_base_view.dart @@ -6,12 +6,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class NetworkBaseView extends StatefulWidget { - final BaseViewModel baseViewModel; - final Widget child; + final BaseViewModel? baseViewModel; + final Widget? child; final bool isLocalLoader; - final bool isLoading; + final bool? isLoading; - NetworkBaseView({Key key, this.baseViewModel, this.child, this.isLocalLoader = false, this.isLoading}); + NetworkBaseView({Key? key, this.baseViewModel, this.child, this.isLocalLoader = false, this.isLoading}); @override _NetworkBaseViewState createState() => _NetworkBaseViewState(); @@ -34,11 +34,11 @@ class _NetworkBaseViewState extends State { child: (widget.baseViewModel != null) ? buildBaseViewWidget() : Center( - child: widget.isLoading + child: widget.isLoading! ? CircularProgressIndicator( backgroundColor: Colors.white, valueColor: AlwaysStoppedAnimation( - Colors.grey[500], + Colors.grey[500]!, ), ) : widget.child, @@ -47,7 +47,7 @@ class _NetworkBaseViewState extends State { } buildBaseViewWidget() { - switch (widget.baseViewModel.state) { + switch (widget.baseViewModel!.state) { case ViewState.ErrorLocal: case ViewState.Idle: case ViewState.BusyLocal: @@ -61,7 +61,7 @@ class _NetworkBaseViewState extends State { child: CircularProgressIndicator( backgroundColor: Colors.white, valueColor: AlwaysStoppedAnimation( - Colors.grey[500], + Colors.grey[500]!, ), ), ), @@ -82,7 +82,7 @@ class _NetworkBaseViewState extends State { case ViewState.Error: return Center( child: AppEmbeddedError( - error: widget.baseViewModel.error, + error: widget.baseViewModel!.error, key: Key("0"), ), ); break; diff --git a/lib/widgets/others/not_auh_page.dart b/lib/widgets/others/not_auh_page.dart index 2a0a3b87..0cf853c5 100644 --- a/lib/widgets/others/not_auh_page.dart +++ b/lib/widgets/others/not_auh_page.dart @@ -21,11 +21,11 @@ import '../../splashPage.dart'; class NotAutPage extends StatefulWidget { final String title; final String description; - final List infoList; - final List imagesInfo; - final String icon; + final List? infoList; + final List? imagesInfo; + final String? icon; - NotAutPage({@required this.title, @required this.description, this.infoList, this.imagesInfo, this.icon}); + NotAutPage({required this.title, required this.description, this.infoList, this.imagesInfo, this.icon}); @override _NotAutPageState createState() => _NotAutPageState(); @@ -57,7 +57,7 @@ class _NotAutPageState extends State { Align( alignment: Alignment.centerLeft, child: SvgPicture.asset( - widget.icon, + widget.icon!, height: 35, width: 35, ), @@ -84,7 +84,7 @@ class _NotAutPageState extends State { ), if (projectViewModel.isInternetConnection && widget.imagesInfo != null) CarouselSlider( - items: widget.imagesInfo.map((image) { + items: widget.imagesInfo!.map((image) { return Builder( builder: (BuildContext context) { return SizedBox( @@ -95,7 +95,7 @@ class _NotAutPageState extends State { }).toList(), options: CarouselOptions( height: MediaQuery.of(context).size.height * 0.55, - autoPlay: widget.imagesInfo.length > 1, + autoPlay: widget.imagesInfo!.length > 1, viewportFraction: 1.0, ), ), @@ -149,7 +149,7 @@ class _NotAutPageState extends State { Align( alignment: Alignment.centerLeft, child: SvgPicture.asset( - widget.icon, + widget.icon!, height: 35, width: 35, ), @@ -176,7 +176,7 @@ class _NotAutPageState extends State { ), if (projectViewModel.isInternetConnection && widget.imagesInfo != null) CarouselSlider( - items: widget.imagesInfo.map((image) { + items: widget.imagesInfo?.map((image) { return Builder( builder: (BuildContext context) { return SizedBox( @@ -187,7 +187,7 @@ class _NotAutPageState extends State { }).toList(), options: CarouselOptions( height: MediaQuery.of(context).size.height * 0.55, - autoPlay: widget.imagesInfo.length > 1, + autoPlay: widget.imagesInfo!.length > 1, viewportFraction: 1.0, ), ), @@ -243,7 +243,7 @@ class _NotAutPageState extends State { ), if (widget.infoList != null) ...List.generate( - widget.infoList.length, + widget.infoList!.length, (index) => Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -264,7 +264,7 @@ class _NotAutPageState extends State { SizedBox( width: 6, ), - Expanded(child: Texts('${widget.infoList[index]}')) + Expanded(child: Texts('${widget.infoList![index]}')) ], ), SizedBox( @@ -287,7 +287,7 @@ class _NotAutPageState extends State { ), if (projectViewModel.isInternetConnection && widget.imagesInfo != null) CarouselSlider( - items: widget.imagesInfo.map((image) { + items: widget.imagesInfo!.map((image) { return Builder( builder: (BuildContext context) { return SizedBox( @@ -298,7 +298,7 @@ class _NotAutPageState extends State { }).toList(), options: CarouselOptions( height: MediaQuery.of(context).size.height * 0.55, - autoPlay: widget.imagesInfo.length > 1, + autoPlay: widget.imagesInfo!.length > 1, viewportFraction: 1.0, ), ), diff --git a/lib/widgets/others/points-expandable-notifier.dart b/lib/widgets/others/points-expandable-notifier.dart index 5f969765..b7857055 100644 --- a/lib/widgets/others/points-expandable-notifier.dart +++ b/lib/widgets/others/points-expandable-notifier.dart @@ -2,10 +2,10 @@ import 'package:expandable/expandable.dart'; import 'package:flutter/material.dart'; class PointsExpandableNotifier extends StatefulWidget { - final Widget headerWidget; - final Widget bodyWidget; - final Widget collapsed; - final bool isExpand; + final Widget? headerWidget; + final Widget? bodyWidget; + final Widget? collapsed; + final bool? isExpand; bool expandFlag = false; var controller = new ExpandableController(); @@ -22,7 +22,7 @@ class _PointsExpandableNotifierState extends State { Widget build(BuildContext context) { setState(() { if (widget.isExpand == true) { - widget.expandFlag = widget.isExpand; + widget.expandFlag = widget.isExpand!; widget.controller.expanded = true; } }); @@ -55,7 +55,7 @@ class _PointsExpandableNotifierState extends State { // }); */ collapsed: Container(), - expanded: widget.bodyWidget, + expanded: widget.bodyWidget!, builder: (_, collapsed, expanded) { return Padding( padding: EdgeInsets.only(left: 0, right: 0, bottom: 0), diff --git a/lib/widgets/others/rounded_container.dart b/lib/widgets/others/rounded_container.dart index 93dc6cc4..6d0af0b2 100644 --- a/lib/widgets/others/rounded_container.dart +++ b/lib/widgets/others/rounded_container.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; class RoundedContainer extends StatefulWidget { - final double width; - final double height; + final double? width; + final double? height; final double raduis; final Color backgroundColor; final double margin; @@ -18,7 +18,7 @@ class RoundedContainer extends StatefulWidget { final double borderWidth; RoundedContainer( - {@required this.child, + {required this.child, this.width, this.height, this.raduis = 10, diff --git a/lib/widgets/others/rounded_container_widget.dart b/lib/widgets/others/rounded_container_widget.dart index 58d9a034..a51600d5 100644 --- a/lib/widgets/others/rounded_container_widget.dart +++ b/lib/widgets/others/rounded_container_widget.dart @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; /// DESCRIPTION : Custom widget for rounded container and custom decoration class RoundedContainer extends StatefulWidget { - final double width; - final double height; + final double? width; + final double? height; final double raduis; final Color backgroundColor; final double margin; @@ -20,9 +20,9 @@ class RoundedContainer extends StatefulWidget { final double borderWidth; RoundedContainer( - {@required this.child, - this.width, - this.height, + {required this.child, + this.width, + this.height, this.raduis = 10, this.backgroundColor = Colors.white, this.margin = 10, diff --git a/lib/widgets/others/sliver_app_bar_delegate.dart b/lib/widgets/others/sliver_app_bar_delegate.dart index 49c9b4fd..c168e7dc 100644 --- a/lib/widgets/others/sliver_app_bar_delegate.dart +++ b/lib/widgets/others/sliver_app_bar_delegate.dart @@ -4,9 +4,9 @@ import 'package:flutter/cupertino.dart'; class SliverAppBarDelegate extends SliverPersistentHeaderDelegate { SliverAppBarDelegate({ - @required this.minHeight, - @required this.maxHeight, - @required this.child, + required this.minHeight, + required this.maxHeight, + required this.child, }); final double minHeight; diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 64c981b2..1aff3f07 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -24,11 +24,11 @@ class SMSOTP { int remainingTime = 120; - Future timer; + Future? timer; - static BuildContext _context; + static BuildContext? _context; - static bool _loading; + static bool? _loading; SMSOTP( this.context, @@ -65,17 +65,17 @@ class SMSOTP { final focusD4 = FocusNode(); - String errorMsg; + String? errorMsg; - ProjectViewModel projectProvider; + ProjectViewModel? projectProvider; - String displayTime = ''; + String? displayTime = ''; - String _code; + String? _code; dynamic setState; - static String signature; + static String? signature; displayDialog(BuildContext context) async { // var signature = await checkSignature(); @@ -149,7 +149,7 @@ class SMSOTP { maxLength: 4, onTextChanged: (text) {}, pinBoxColor: Colors.white, - onDone: (code) => _onOtpCallBack(code, null), + onDone: (code) => _onOtpCallBack(code, false), textBorderColor: Color(0xffD8D8D8), pinBoxWidth: 60, pinBoxHeight: 60, @@ -221,7 +221,7 @@ class SMSOTP { ); } - String validateCodeDigit(value) { + String? validateCodeDigit(value) { if (value.isEmpty) { return ' '; } else if (value.length == 3) { @@ -234,7 +234,7 @@ class SMSOTP { checkValue() { //print(verifyAccountFormValue); - if (verifyAccountForm.currentState.validate()) { + if (verifyAccountForm.currentState!.validate()) { onSuccess(digit1.text.toString() + digit2.text.toString() + digit3.text.toString() + digit4.text.toString()); } } diff --git a/lib/widgets/otp_widget.dart b/lib/widgets/otp_widget.dart index f44f255b..99d0f2f5 100644 --- a/lib/widgets/otp_widget.dart +++ b/lib/widgets/otp_widget.dart @@ -23,7 +23,7 @@ class ProvidedPinBoxTextAnimation { class OTPWidget extends StatefulWidget { final int maxLength; - final TextEditingController controller; + late TextEditingController? controller; final Color defaultBorderColor; final Color pinBoxColor; @@ -31,41 +31,41 @@ class OTPWidget extends StatefulWidget { final double pinBoxRadius; final bool hideDefaultKeyboard; - final TextStyle pinTextStyle; + final TextStyle? pinTextStyle; final double pinBoxHeight; final double pinBoxWidth; - final OnDone onDone; + final OnDone? onDone; final bool hasError; final Color errorBorderColor; final Color textBorderColor; - final Function(String) onTextChanged; + final Function(String)? onTextChanged; final bool autoFocus; - final FocusNode focusNode; - final AnimatedSwitcherTransitionBuilder pinTextAnimatedSwitcherTransition; + final FocusNode? focusNode; + final AnimatedSwitcherTransitionBuilder? pinTextAnimatedSwitcherTransition; final Duration pinTextAnimatedSwitcherDuration; final TextDirection textDirection; final TextInputType keyboardType; final EdgeInsets pinBoxOuterPadding; - const OTPWidget({ - Key key, - this.maxLength: 4, + OTPWidget({ + Key? key, + this.maxLength = 4, this.controller, - this.pinBoxWidth: 70.0, - this.pinBoxHeight: 70.0, + this.pinBoxWidth = 70.0, + this.pinBoxHeight = 70.0, this.pinTextStyle, this.onDone, - this.defaultBorderColor: Colors.black, - this.textBorderColor: Colors.black, + this.defaultBorderColor = Colors.black, + this.textBorderColor = Colors.black, this.pinTextAnimatedSwitcherTransition, - this.pinTextAnimatedSwitcherDuration: const Duration(), - this.hasError: false, - this.errorBorderColor: Colors.red, + this.pinTextAnimatedSwitcherDuration= const Duration(), + this.hasError= false, + this.errorBorderColor= Colors.red, this.onTextChanged, - this.autoFocus: false, + this.autoFocus= false, this.focusNode, - this.textDirection: TextDirection.ltr, - this.keyboardType: TextInputType.number, + this.textDirection= TextDirection.ltr, + this.keyboardType= TextInputType.number, this.pinBoxOuterPadding = const EdgeInsets.symmetric(horizontal: 4.0), this.pinBoxColor = Colors.white, this.pinBoxBorderWidth = 2.0, @@ -80,8 +80,8 @@ class OTPWidget extends StatefulWidget { } class OTPWidgetState extends State with SingleTickerProviderStateMixin { - AnimationController _highlightAnimationController; - FocusNode focusNode; + late AnimationController _highlightAnimationController; + late FocusNode focusNode; String text = ""; int currentIndex = 0; List strList = []; diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index 105d7503..2abb9224 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -6,9 +6,9 @@ import 'bottom_nav_pharmacy_home_item.dart'; import 'bottom_nav_pharmacy_item.dart'; class BottomNavPharmacyBar extends StatefulWidget { - final ValueChanged changeIndex; + ValueChanged changeIndex; - BottomNavPharmacyBar({Key key, this.changeIndex, this.index}) : super(key: key); + BottomNavPharmacyBar({Key? key, required this.changeIndex, required this.index}) : super(key: key); int index = 0; @override @@ -17,9 +17,11 @@ class BottomNavPharmacyBar extends StatefulWidget { class _BottomNavPharmacyBarState extends State { _changeIndex(int index) { - widget.changeIndex(index); + widget.changeIndex!(index); + } + changeIndex() { + widget.changeIndex!(widget.index); } - @override Widget build(BuildContext context) { return BottomAppBar( @@ -35,7 +37,7 @@ class _BottomNavPharmacyBarState extends State { BottomNavHomeItem( icon: Icons.image, activeIcon: Icons.image, - changeIndex: _changeIndex, + changeIndex: changeIndex, index: widget.index, currentIndex: 0, title: TranslationBase.of(context).Alhabibapp, diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart index 28217b8b..fe0e2c48 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart @@ -5,15 +5,15 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; class BottomNavHomeItem extends StatelessWidget { - final IconData icon; - final Image image; - final String title; + final IconData? icon; + final Image? image; + final String? title; - final Function changeIndex; - final int index; - final int currentIndex; - final Function onTap; - final IconData activeIcon; + final VoidCallback? changeIndex; + final int? index; + final int? currentIndex; + final VoidCallback? onTap; + final IconData? activeIcon; BottomNavHomeItem( {this.icon, @@ -69,7 +69,7 @@ class BottomNavHomeItem extends StatelessWidget { Container( margin: EdgeInsets.only(bottom: 7.0), child: Texts( - title, + title!, textAlign: TextAlign.start, color: currentIndex == index ? Colors.grey : Colors.grey, fontSize: 11, diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 1d5893fd..909f863d 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -12,18 +12,18 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class BottomNavPharmacyItem extends StatelessWidget { - final String title; - final IconData icon; + final String? title; + final IconData? icon; final ValueChanged changeIndex; - final int index; - final int currentIndex; - final Function onTap; - final bool isHome; + final int? index; + final int? currentIndex; + final VoidCallbackAction? onTap; + final bool? isHome; - final IconData activeIcon; + final IconData? activeIcon; - BottomNavPharmacyItem({this.icon, this.changeIndex, this.index, this.currentIndex, this.activeIcon, this.title, this.onTap, this.isHome = false}); + BottomNavPharmacyItem({required this.icon, required this.changeIndex, this.index, this.currentIndex, this.activeIcon, this.title, this.onTap, this.isHome = false}); AppSharedPreferences sharedPref = AppSharedPreferences(); @@ -47,7 +47,7 @@ class BottomNavPharmacyItem extends StatelessWidget { if (!Provider.of(context, listen: false).isLogin && (currentIndex == 2 || currentIndex == 3)) login(context); else - changeIndex(currentIndex); + changeIndex(currentIndex!); }, child: Column( mainAxisSize: MainAxisSize.min, @@ -64,7 +64,7 @@ class BottomNavPharmacyItem extends StatelessWidget { Container( child: Icon(currentIndex == index ? activeIcon : icon, - color: isHome + color: isHome! ? Color(0xff5AB145) : currentIndex == index ? Colors.grey @@ -77,7 +77,7 @@ class BottomNavPharmacyItem extends StatelessWidget { // Added TextAlign Property Texts( - title, + title!, textAlign: TextAlign.center, color: currentIndex == index ? Colors.grey : Colors.grey, fontWeight: currentIndex == index ? FontWeight.normal : FontWeight.w400, diff --git a/lib/widgets/pharmacy/drug_item.dart b/lib/widgets/pharmacy/drug_item.dart index d9ffcd1c..28f1df69 100644 --- a/lib/widgets/pharmacy/drug_item.dart +++ b/lib/widgets/pharmacy/drug_item.dart @@ -11,10 +11,10 @@ class MedicineItemWidget extends StatefulWidget { final Color backgroundColor; final bool showBorder; final Color borderColor; - final String url; + final String? url; MedicineItemWidget( - {@required this.label, + {required this.label, this.backgroundColor = Colors.white, this.showBorder = false, this.borderColor = Colors.white, @@ -42,7 +42,7 @@ class _MedicineItemWidgetState extends State { child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(7)), child: Image.memory( - dataFromBase64String(widget.url), + dataFromBase64String(widget.url!), height: SizeConfig.imageSizeMultiplier * 11, width: SizeConfig.imageSizeMultiplier * 11, fit: BoxFit.cover, diff --git a/lib/widgets/pharmacy/my_account_items.dart b/lib/widgets/pharmacy/my_account_items.dart index bb514e57..8a2a7293 100644 --- a/lib/widgets/pharmacy/my_account_items.dart +++ b/lib/widgets/pharmacy/my_account_items.dart @@ -3,8 +3,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_svg/flutter_svg.dart'; class AccountItem extends StatelessWidget { - final String title; - final String itemIcon; + final String? title; + final String? itemIcon; final bool isTerms; const AccountItem({this.title, this.itemIcon, this.isTerms = false}); @@ -39,7 +39,7 @@ class AccountItem extends StatelessWidget { width: 20, ), Texts( - title, + title!, fontSize: 15.0, ), ], diff --git a/lib/widgets/pharmacy/my_account_services.dart b/lib/widgets/pharmacy/my_account_services.dart index e3b9948d..8da55305 100644 --- a/lib/widgets/pharmacy/my_account_services.dart +++ b/lib/widgets/pharmacy/my_account_services.dart @@ -5,9 +5,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; class AccountServices extends StatelessWidget { - final String title; - final String serviceImage; - final Function onTap; + final String? title; + final String? serviceImage; + final VoidCallback? onTap; const AccountServices({this.title, this.onTap, this.serviceImage}); @@ -40,7 +40,7 @@ class AccountServices extends StatelessWidget { height: 7, ), Texts( - title, + title!, fontSize: 15.0, fontWeight: FontWeight.bold, ), diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 5e8c4cf7..7a511cbd 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -9,26 +9,27 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; + class productTile extends StatelessWidget { - final String productName; - final String productPrice; - final double productRate; - final int productReviews; - final String qyt; - final String totalPrice; + final String? productName; + final String? productPrice; + final double? productRate; + final int? productReviews; + final String? qyt; + final String? totalPrice; final bool isOrderDetails; - final String productImage; + final String? productImage; final bool showLine; - final String img; - final String imgs; - final int status; - final PharmacyProduct product; + final String? img; + final String? imgs; + final int? status; + final PharmacyProduct? product; final dynamic productID; - final Function onDelete; + final Function? onDelete; final dynamic approvedTotalReviews; final dynamic isRx; @@ -66,11 +67,11 @@ class productTile extends StatelessWidget { children: [ Row( children: [ - this.imgs != null && this.imgs.length > 0 + this.imgs != null && this.imgs!.length > 0 ? Container( margin: EdgeInsets.only(left: 10), child: Image.network( - imgs, + imgs!, // productImage.trim(), fit: BoxFit.cover, width: 80, @@ -80,7 +81,7 @@ class productTile extends StatelessWidget { : Container( margin: EdgeInsets.only(left: 10), child: Image.network( - productImage, + productImage!, width: 80, height: 80, ) @@ -154,15 +155,23 @@ class productTile extends StatelessWidget { margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: productRate, - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + child: RatingBar.builder( + initialRating: productRate!, + // size: 15.0, + // filledColor: Colors.yellow[700], + // emptyColor: Colors.grey[500], + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: Icons.star, + // emptyIcon: Icons.star, + itemBuilder: (BuildContext context, int index) => Icon( + Icons.star, + color: Colors.yellow[700], + size: 15, + ), onRatingUpdate: (double value) { + + }, + ), ), ), @@ -189,7 +198,7 @@ class productTile extends StatelessWidget { onPressed: () { GifLoaderDialogUtils.showMyDialog(context); // deleteFromWishlistFunction(productID); - onDelete(productID); + onDelete!(productID); GifLoaderDialogUtils.hideDialog(context); }, ), @@ -287,15 +296,15 @@ class productTile extends StatelessWidget { // margin: EdgeInsets.all(5.0), child: Align( alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: productRate, - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + child: RatingBar( + initialRating: productRate!, + //size: 15.0, + // filledColor: , + // emptyColor: , + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: , + ratingWidget: RatingWidget(full: Icon(Icons.star, color:Colors.yellow[700], size: 15,), half: Icon(Icons.star_half, color:Colors.grey[500], size: 15), empty: Icon(Icons.star_half, color:Colors.grey[500], size: 15)), onRatingUpdate: (double value) { }, ), ), ), @@ -319,7 +328,7 @@ class productTile extends StatelessWidget { InkWell( onTap: () { Navigator.push( - context, FadePage(page: ProductReviewPage(product))); + context, FadePage(page: ProductReviewPage(product!))); }, child: Container( padding: diff --git a/lib/widgets/pickupLocation/PickupLocationFromMap.dart b/lib/widgets/pickupLocation/PickupLocationFromMap.dart index d8aa1642..1bca28aa 100644 --- a/lib/widgets/pickupLocation/PickupLocationFromMap.dart +++ b/lib/widgets/pickupLocation/PickupLocationFromMap.dart @@ -12,20 +12,22 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:geocoding/geocoding.dart'; -import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart' as googleMap; import 'package:google_maps_place_picker_mb/google_maps_place_picker.dart'; import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; +import 'package:huawei_map/components/cameraPosition.dart'; +import 'package:huawei_map/components/latLng.dart'; import 'package:provider/provider.dart'; class PickupLocationFromMap extends StatefulWidget { - final Function(LocationDetails) onPick; - final double latitude; - final double longitude; - final bool isWithAppBar; - final String buttonLabel; - final Color buttonColor; + final Function(LocationDetails)? onPick; + final double? latitude; + final double? longitude; + final bool? isWithAppBar; + final String? buttonLabel; + final Color? buttonColor; - const PickupLocationFromMap({Key key, this.onPick, this.latitude, this.longitude, this.isWithAppBar = true, this.buttonLabel, this.buttonColor}) : super(key: key); + const PickupLocationFromMap({Key? key, this.onPick, this.latitude, this.longitude, this.isWithAppBar = true, this.buttonLabel, this.buttonColor}) : super(key: key); @override State createState() => _PickupLocationFromMapState(); @@ -33,14 +35,14 @@ class PickupLocationFromMap extends StatefulWidget { class _PickupLocationFromMapState extends State { bool isHuawei = false; - Placemark selectedPlace; - AppMap appMap; - LatLng currentPostion; + late Placemark selectedPlace; + late AppMap appMap; + late LatLng currentPostion; AppSharedPreferences sharedPref = AppSharedPreferences(); double latitude = 0; double longitude = 0; - HmsApiAvailability hmsApiAvailability; + late HmsApiAvailability hmsApiAvailability; static CameraPosition kGooglePlex = CameraPosition( target: LatLng(24.126613,45.081137), @@ -60,9 +62,9 @@ class _PickupLocationFromMapState extends State { _updatePosition(camera); }, onMapCreated: () { - currentPostion = LatLng(widget.latitude, widget.longitude); - latitude = widget.latitude; - longitude = widget.longitude; + currentPostion = LatLng(widget.latitude!, widget.longitude!); + latitude = widget.latitude!; + longitude = widget.longitude!; setState(() {}); }, onCameraIdle: () async { @@ -118,8 +120,8 @@ class _PickupLocationFromMapState extends State { LocationDetails locationDetails = new LocationDetails(); locationDetails.lat = latitude; locationDetails.long = longitude; - locationDetails.formattedAddress = selectedPlace.street; - widget.onPick(locationDetails); + locationDetails.formattedAddress = selectedPlace.street!; + widget.onPick!(locationDetails); Navigator.of(context).pop(); }), ), @@ -137,9 +139,9 @@ class _PickupLocationFromMapState extends State { LocationDetails locationDetails = new LocationDetails(); locationDetails.lat = latitude; locationDetails.long = longitude; - locationDetails.formattedAddress = result.formattedAddress; + locationDetails.formattedAddress = result.formattedAddress!; print(result.adrAddress); - widget.onPick(locationDetails); + widget.onPick!(locationDetails); Navigator.of(context).pop(); }, selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { @@ -160,17 +162,17 @@ class _PickupLocationFromMapState extends State { TranslationBase.of(context).next, () { LocationDetails locationDetails = new LocationDetails(); - locationDetails.lat = selectedPlace.geometry.location.lat; - locationDetails.long = selectedPlace.geometry.location.lng; - locationDetails.formattedAddress = selectedPlace.formattedAddress; - widget.onPick(locationDetails); + locationDetails.lat = selectedPlace!.geometry!.location.lat; + locationDetails.long = selectedPlace.geometry!.location.lng; + locationDetails.formattedAddress = selectedPlace.formattedAddress!; + widget.onPick!(locationDetails); Navigator.of(context).pop(); }, ), ), ); }, - initialPosition: LatLng(projectViewModel.latitude, projectViewModel.longitude), + initialPosition: googleMap.LatLng(projectViewModel.latitude, projectViewModel.longitude), useCurrentLocation: true, ), ); @@ -178,7 +180,7 @@ class _PickupLocationFromMapState extends State { void _updatePosition(CameraPosition _position) { print(_position); - latitude = _position.target.latitude; - longitude = _position.target.longitude; + latitude = _position.target.lat; + longitude = _position.target.lng; } } diff --git a/lib/widgets/progress_indicator/app_circular_progress_Indeicator.dart b/lib/widgets/progress_indicator/app_circular_progress_Indeicator.dart index f76f52fa..0e2df2d7 100644 --- a/lib/widgets/progress_indicator/app_circular_progress_Indeicator.dart +++ b/lib/widgets/progress_indicator/app_circular_progress_Indeicator.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; /// Show Progress Indicator class AppCircularProgressIndicator extends StatelessWidget { const AppCircularProgressIndicator({ - Key key, + Key? key, }) : super(key: key); @override diff --git a/lib/widgets/progress_indicator/app_loader_widget.dart b/lib/widgets/progress_indicator/app_loader_widget.dart index 33984957..d4c55d66 100644 --- a/lib/widgets/progress_indicator/app_loader_widget.dart +++ b/lib/widgets/progress_indicator/app_loader_widget.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:progress_hud_v2/progress_hud.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; /// show app Loader /// [backgroundColor] the background color for the app loader /// [color] the color for the app loader class AppLoaderWidget extends StatefulWidget { AppLoaderWidget( - {Key key, + {Key? key, this.backgroundColor = Colors.black12, this.color = Colors.black}) : super(key: key); @@ -19,7 +19,7 @@ class AppLoaderWidget extends StatefulWidget { } class _AppLoaderWidgetState extends State { - ProgressHUD _progressHUD; + late ProgressHUD _progressHUD; @override void initState() { @@ -28,8 +28,8 @@ class _AppLoaderWidgetState extends State { /// create progress Hud Indicator _progressHUD = new ProgressHUD( backgroundColor: widget.backgroundColor, - color: widget.color, - borderRadius: 5.0, + indicatorColor: widget.color, + child: SizedBox(), ); } diff --git a/lib/widgets/single_selection_dialog.dart b/lib/widgets/single_selection_dialog.dart index 155f6394..02c2acf2 100644 --- a/lib/widgets/single_selection_dialog.dart +++ b/lib/widgets/single_selection_dialog.dart @@ -15,9 +15,9 @@ class SingleSelectionDialog extends StatefulWidget { final String title; final Widget icon; - SingleSelectionDialog(this.items, {@required this.icon, @required this.title}); + SingleSelectionDialog(this.items, {required this.icon, required this.title}); - Future show(BuildContext context) async { + Future> show(BuildContext context) async { return showDialog( context: context, barrierDismissible: true, // user must tap button! @@ -108,9 +108,9 @@ class _SingleSelectionDialogState extends State { Radio( value: idx, groupValue: i, - onChanged: (int value) { + onChanged: (int? value) { setState(() { - i = value; + i = value!; }); }, ), diff --git a/lib/widgets/text/app_texts_widget.dart b/lib/widgets/text/app_texts_widget.dart index ea62e89a..15697e69 100644 --- a/lib/widgets/text/app_texts_widget.dart +++ b/lib/widgets/text/app_texts_widget.dart @@ -10,21 +10,21 @@ import 'package:provider/provider.dart'; class AppText extends StatefulWidget { final String data; - final Color color; + final Color? color; final FontWeight fontWeight; - final double fontSize; - final String fontFamily; - final double margin; + final double? fontSize; + final String? fontFamily; + final double? margin; final double marginTop; final double marginRight; final double marginBottom; final double marginLeft; final bool visibility; - final TextAlign textAlign; + final TextAlign? textAlign; final Color backGroundcolor; final bool underline; - final double height; - final double letterSpacing; + final double? height; + final double? letterSpacing; AppText(this.data, {this.color, @@ -55,14 +55,14 @@ class _AppTextState extends State { return Visibility( visible: widget.visibility, child: Container( - margin: widget.margin != null ? EdgeInsets.all(widget.margin) : EdgeInsets.only(top: widget.marginTop, right: widget.marginRight, bottom: widget.marginBottom, left: widget.marginLeft), + margin: widget.margin != null ? EdgeInsets.all(widget.margin!) : EdgeInsets.only(top: widget.marginTop, right: widget.marginRight, bottom: widget.marginBottom, left: widget.marginLeft), child: Text( widget.data, textAlign: widget.textAlign, overflow: TextOverflow.clip, style: TextStyle( - color: widget.color == null ? Theme.of(context).textTheme.bodyText1.color : widget.color, + color: widget.color == null ? Theme.of(context).textTheme.bodyText1!.color : widget.color, fontWeight: widget.fontWeight, fontSize: widget.fontSize ?? (SizeConfig.textMultiplier * 2), height: widget.height, diff --git a/lib/widgets/transitions/fade_page.dart b/lib/widgets/transitions/fade_page.dart index a538b1c4..620e22dd 100644 --- a/lib/widgets/transitions/fade_page.dart +++ b/lib/widgets/transitions/fade_page.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; class FadePage extends PageRouteBuilder { final Widget page; - FadePage({this.page}) + FadePage({required this.page}) : super( opaque: false, fullscreenDialog: true, diff --git a/lib/widgets/transitions/slide_up_page.dart b/lib/widgets/transitions/slide_up_page.dart index 2c138b9e..8d5f0fe0 100644 --- a/lib/widgets/transitions/slide_up_page.dart +++ b/lib/widgets/transitions/slide_up_page.dart @@ -11,7 +11,7 @@ class SlideUpPageRoute extends PageRouteBuilder { final bool opaque; SlideUpPageRoute( - {this.widget, this.fullscreenDialog = false, this.opaque = true}) + {required this.widget, this.fullscreenDialog = false, this.opaque = true}) : super( pageBuilder: ( BuildContext context, diff --git a/lib/widgets/typewriter/typewiter.dart b/lib/widgets/typewriter/typewiter.dart index e8ca178a..d596bb85 100644 --- a/lib/widgets/typewriter/typewiter.dart +++ b/lib/widgets/typewriter/typewiter.dart @@ -5,16 +5,16 @@ import 'package:flutter/material.dart'; class TyperAnimatedTextKit extends StatefulWidget { final String text; final int textLength; - TyperAnimatedTextKit({this.text, this.textLength}); + TyperAnimatedTextKit({required this.text, required this.textLength}); @override _TyperState createState() => _TyperState(); } class _TyperState extends State with TickerProviderStateMixin { - Animation _characterCount; - AnimationController _controller; - int _stringIndex; + late Animation _characterCount; + late AnimationController _controller; + late int _stringIndex; var event = RobotProvider(); @override void initState() { @@ -65,7 +65,7 @@ class _TyperState extends State ? null : new AnimatedBuilder( animation: _characterCount, - builder: (BuildContext context, Widget child) { + builder: (BuildContext context, Widget? child) { String text = widget.text.substring(0, _characterCount.value); return AppText( text, diff --git a/lib/widgets/weather_slider/weather_slider.dart b/lib/widgets/weather_slider/weather_slider.dart index 0e784a05..87bf1c37 100644 --- a/lib/widgets/weather_slider/weather_slider.dart +++ b/lib/widgets/weather_slider/weather_slider.dart @@ -11,11 +11,11 @@ class WeatherSlider extends StatelessWidget { WeatherSlider(this.data, this.projectViewModel); - LinearGradient red = LinearGradient(colors: [Colors.redAccent[100], Colors.redAccent]); - LinearGradient green = LinearGradient(colors: [Colors.greenAccent[100], Colors.greenAccent]); - LinearGradient grey = LinearGradient(colors: [Colors.grey[100], Colors.grey]); - LinearGradient orange = LinearGradient(colors: [Colors.orangeAccent[100], Colors.orange]); - LinearGradient yellow = LinearGradient(colors: [Colors.yellow[100], Colors.yellow[600]]); + LinearGradient red = LinearGradient(colors: [Colors.redAccent[100]!, Colors.redAccent]); + LinearGradient green = LinearGradient(colors: [Colors.greenAccent[100]!, Colors.greenAccent]); + LinearGradient grey = LinearGradient(colors: [Colors.grey[100]!, Colors.grey]); + LinearGradient orange = LinearGradient(colors: [Colors.orangeAccent[100]!, Colors.orange]); + LinearGradient yellow = LinearGradient(colors: [Colors.yellow[100]!, Colors.yellow[600]!]); @override Widget build(BuildContext context) { @@ -34,7 +34,7 @@ class WeatherSlider extends StatelessWidget { children: [ Container( margin: EdgeInsets.only(bottom: 10), - decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.grey[100], Colors.grey[400]]), borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.grey[100]!, Colors.grey[400]!]), borderRadius: BorderRadius.circular(10)), height: 15, width: MediaQuery.of(context).size.width, child: SizedBox(), @@ -109,35 +109,35 @@ class WeatherSlider extends StatelessWidget { AppText(data.categoriesNames.category1, fontSize: 12, color: data.categoriesNames.category1 == data.category && data.colorName == 'red' - ? Colors.redAccent + ? Colors.redAccent! : data.categoriesNames.category1 == data.category && data.colorName == 'orange' - ? Colors.orangeAccent + ? Colors.orangeAccent! : data.categoriesNames.category1 == data.category && data.colorName == 'green' - ? Colors.greenAccent + ? Colors.greenAccent! : data.categoriesNames.category1 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] - : Colors.black), + ? Colors.yellow[900]! + : Colors.black!), AppText(data.categoriesNames.category2, fontSize: 12, color: data.categoriesNames.category2 == data.category && data.colorName == 'red' - ? Colors.redAccent + ? Colors.redAccent! : data.categoriesNames.category2 == data.category && data.colorName == 'orange' - ? Colors.orangeAccent + ? Colors.orangeAccent! : data.categoriesNames.category2 == data.category && data.colorName == 'green' - ? Colors.greenAccent + ? Colors.greenAccent! : data.categoriesNames.category2 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), AppText(data.categoriesNames.category3, fontSize: 12, color: data.categoriesNames.category3 == data.category && data.colorName == 'red' - ? Colors.redAccent + ? Colors.redAccent! : data.categoriesNames.category3 == data.category && data.colorName == 'orange' - ? Colors.orangeAccent + ? Colors.orangeAccent! : data.categoriesNames.category3 == data.category && data.colorName == 'green' - ? Colors.greenAccent + ? Colors.greenAccent! : data.categoriesNames.category3 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), AppText(data.categoriesNames.category4, fontSize: 12, @@ -148,7 +148,7 @@ class WeatherSlider extends StatelessWidget { : data.categoriesNames.category4 == data.category && data.colorName == 'green' ? Colors.greenAccent : data.categoriesNames.category4 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), AppText(data.categoriesNames.category5, fontSize: 12, @@ -159,7 +159,7 @@ class WeatherSlider extends StatelessWidget { : data.categoriesNames.category5 == data.category && data.colorName == 'green' ? Colors.greenAccent : data.categoriesNames.category5 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), ], ) @@ -175,7 +175,7 @@ class WeatherSlider extends StatelessWidget { : data.categoriesNames.category5 == data.category && data.colorName == 'green' ? Colors.greenAccent : data.categoriesNames.category5 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), AppText(data.categoriesNames.category4, fontSize: 12, @@ -186,7 +186,7 @@ class WeatherSlider extends StatelessWidget { : data.categoriesNames.category4 == data.category && data.colorName == 'green' ? Colors.greenAccent : data.categoriesNames.category4 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), AppText(data.categoriesNames.category3, fontSize: 12, @@ -197,7 +197,7 @@ class WeatherSlider extends StatelessWidget { : data.categoriesNames.category3 == data.category && data.colorName == 'green' ? Colors.greenAccent : data.categoriesNames.category3 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), AppText(data.categoriesNames.category2, fontSize: 12, @@ -208,7 +208,7 @@ class WeatherSlider extends StatelessWidget { : data.categoriesNames.category2 == data.category && data.colorName == 'green' ? Colors.greenAccent : data.categoriesNames.category2 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), AppText(data.categoriesNames.category1, fontSize: 12, @@ -219,7 +219,7 @@ class WeatherSlider extends StatelessWidget { : data.categoriesNames.category1 == data.category && data.colorName == 'green' ? Colors.greenAccent : data.categoriesNames.category1 == data.category && data.colorName == 'yellow' - ? Colors.yellow[900] + ? Colors.yellow[900]! : Colors.black), ], )), @@ -239,11 +239,11 @@ class MessageBorder extends ShapeBorder { EdgeInsetsGeometry get dimensions => EdgeInsets.only(bottom: usePadding ? 0 : 0); @override - Path getInnerPath(Rect rect, {TextDirection textDirection}) => null; + Path getInnerPath(Rect rect, { TextDirection? textDirection}) => Path(); @override - Path getOuterPath(Rect rect, {TextDirection textDirection}) { - rect = Rect.fromPoints(rect.bottomRight, rect.bottomLeft - Offset(0, 0)); + Path getOuterPath( Rect rect, { TextDirection? textDirection}) { + rect = Rect.fromPoints(rect!.bottomRight, rect!.bottomLeft - Offset(0, 0)); if (!reverse) { return Path() ..addRRect(RRect.fromRectAndRadius(rect, Radius.circular(rect.height / 2))) @@ -262,7 +262,7 @@ class MessageBorder extends ShapeBorder { } @override - void paint(Canvas canvas, Rect rect, {TextDirection textDirection}) {} + void paint(Canvas? canvas, Rect? rect, {TextDirection? textDirection}) {} @override ShapeBorder scale(double t) => this; diff --git a/pubspec.yaml b/pubspec.yaml index 9f3755da..466cfe7b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ description: A new Flutter application. version: 4.5.026+4050026 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=3.0.0 <3.13.0" dependencies: flutter: @@ -13,7 +13,7 @@ dependencies: # Localizations flutter_localizations: sdk: flutter - intl: ^0.17.0 + intl: ^0.18.1 # web view # webview_flutter: ^2.3.1 @@ -49,7 +49,7 @@ dependencies: pull_to_refresh: ^2.0.0 # Native - local_auth: ^1.1.8 + local_auth: ^2.1.7 localstorage: ^4.0.0+1 maps_launcher: ^2.0.1 url_launcher: ^6.0.15 @@ -61,7 +61,7 @@ dependencies: # Progress bar - progress_hud_v2: ^2.0.0 + flutter_progress_hud: ^2.0.2 percent_indicator: ^3.4.0 # Icons @@ -72,12 +72,13 @@ dependencies: image_picker: ^0.8.5+3 #GIF image - flutter_gifimage: ^1.0.1 +# flutter_gifimage: ^1.0.1 + flutter_gif: ^0.0.4 photo_view: any # flutter_webrtc: any # UI Reqs - expandable: ^4.1.4 + expandable: ^5.0.1 # Notification Banner # dropdown_banner: ^1.4.0 @@ -85,7 +86,7 @@ dependencies: # flutter_local_notifications: # charts - charts_flutter: ^0.12.0 +# charts_flutter: ^0.12.0 google_maps_flutter: ^2.1.1 @@ -102,7 +103,7 @@ dependencies: barcode_scan2: ^4.2.2 # Rating Stars - rating_bar: ^0.2.0 + flutter_rating_bar: ^4.0.1 # Calendar syncfusion_flutter_calendar: ^19.3.55 @@ -123,13 +124,13 @@ dependencies: just_audio: ^0.9.30 #hijri - hijri: ^2.0.3 + hijri: ^3.0.0 #datetime_picker flutter_datetime_picker: ^1.5.1 # Carousel - carousel_pro: ^1.0.0 - +# carousel_pro: ^1.0.0 //8/oct + carousel_pro_nullsafety: ^2.0.0 #local_notifications flutter_local_notifications: any @@ -142,7 +143,7 @@ dependencies: #Handle lat long to address geocoding: ^2.0.1 - jiffy: ^4.1.0 + jiffy: ^6.2.1 #Flutter WebRTC flutter_webrtc: ^0.9.7 @@ -153,7 +154,7 @@ dependencies: google_maps_place_picker_mb: ^3.0.0 # google_maps_place_picker: ^2.1.0-nullsafety.3 - map_launcher: ^1.1.3 + map_launcher: ^2.5.0+1 #countdown timer for Upcoming List flutter_countdown_timer: ^4.1.0 @@ -167,12 +168,12 @@ dependencies: # path: flutter_tts-voice_enhancement flutter_tts: ^3.6.1 - wifi: ^0.1.5 +# wifi: ^0.1.5 //18/oct vibration: ^1.7.3 flutter_nfc_kit: ^3.3.1 - geofencing: ^0.1.0 +# geofencing: ^0.1.0 //18/oct speech_to_text: ^6.1.1 # path: speech_to_text @@ -184,8 +185,8 @@ dependencies: badges: ^2.0.1 flutter_app_icon_badge: ^2.0.0 # syncfusion_flutter_sliders: ^19.3.55 - searchable_dropdown: ^1.1.3 - dropdown_search: 0.4.9 +# searchable_dropdown: ^1.1.3 + dropdown_search: 5.0.6 youtube_player_flutter: ^8.0.0 # Dep by Zohaib @@ -205,9 +206,9 @@ dependencies: wave: ^0.2.0 # sms_retriever: ^1.0.0 sms_otp_auto_verify: ^2.1.0 - flutter_ios_voip_kit: ^0.0.5 + flutter_ios_voip_kit: ^0.1.0 google_api_availability: ^3.0.1 -# open_file: ^3.2.1 + # open_file: ^3.2.1 open_filex: ^4.3.2 path_provider: ^2.0.8 # flutter_callkit_incoming: ^1.0.3+3