From bb20b4d582f0c65f5960d93df4954c5877a4e2a9 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 16 Jun 2021 11:46:24 +0300 Subject: [PATCH] flutter 2 migration --- lib/client/base_app_client.dart | 7 +++-- ...on_code_for_doctor_app_response_model.dart | 28 ++++++------------- .../viewModel/authentication_view_model.dart | 14 +++++----- .../auth/verification_methods_screen.dart | 6 ++-- lib/screens/home/home_page_card.dart | 4 +-- lib/screens/home/home_patient_card.dart | 2 +- .../out_patient/out_patient_screen.dart | 6 ++-- .../prescription/add_prescription_form.dart | 24 ++++++++-------- .../procedures/ExpansionProcedure.dart | 22 +++++++-------- lib/screens/procedures/ProcedureCard.dart | 4 +-- lib/widgets/patients/PatientCard.dart | 4 +-- 11 files changed, 55 insertions(+), 66 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 5d55c03e..bba61c2a 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -31,10 +31,11 @@ class BaseAppClient { bool callLog = true; try { - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + Map? profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); - DoctorProfileModel ? doctorProfile = DoctorProfileModel.fromJson(profile); - if (doctorProfile!=null) { + DoctorProfileModel? doctorProfile; + if (profile != null) { + doctorProfile = DoctorProfileModel.fromJson(profile); if (body['DoctorID'] == null) body['DoctorID'] = doctorProfile.doctorID; if (body['DoctorID'] == "") body['DoctorID'] = null; if (body['EditedBy'] == null) body['EditedBy'] = doctorProfile.doctorID; diff --git a/lib/core/model/auth/check_activation_code_for_doctor_app_response_model.dart b/lib/core/model/auth/check_activation_code_for_doctor_app_response_model.dart index 0d9e5149..0ae3008e 100644 --- a/lib/core/model/auth/check_activation_code_for_doctor_app_response_model.dart +++ b/lib/core/model/auth/check_activation_code_for_doctor_app_response_model.dart @@ -3,16 +3,13 @@ import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; class CheckActivationCodeForDoctorAppResponseModel { late String? authenticationTokenID; late List? listDoctorsClinic; - late List? listDoctorProfile; + List? listDoctorProfile; late MemberInformation? memberInformation; CheckActivationCodeForDoctorAppResponseModel( - {this.authenticationTokenID, - this.listDoctorsClinic, - this.memberInformation}); + {this.authenticationTokenID, this.listDoctorsClinic, this.memberInformation}); - CheckActivationCodeForDoctorAppResponseModel.fromJson( - Map json) { + CheckActivationCodeForDoctorAppResponseModel.fromJson(Map json) { authenticationTokenID = json['AuthenticationTokenID']; if (json['List_DoctorsClinic'] != null) { listDoctorsClinic = []; @@ -28,22 +25,19 @@ class CheckActivationCodeForDoctorAppResponseModel { }); } - memberInformation = json['memberInformation'] != null - ? new MemberInformation.fromJson(json['memberInformation']) - : null; + memberInformation = + json['memberInformation'] != null ? new MemberInformation.fromJson(json['memberInformation']) : null; } Map toJson() { final Map data = new Map(); data['AuthenticationTokenID'] = this.authenticationTokenID; if (this.listDoctorsClinic != null) { - data['List_DoctorsClinic'] = - this.listDoctorsClinic!.map((v) => v.toJson()).toList(); + data['List_DoctorsClinic'] = this.listDoctorsClinic!.map((v) => v.toJson()).toList(); } if (this.listDoctorProfile != null) { - data['List_DoctorProfile'] = - this.listDoctorProfile!.map((v) => v.toJson()).toList(); + data['List_DoctorProfile'] = this.listDoctorProfile!.map((v) => v.toJson()).toList(); } if (this.memberInformation != null) { data['memberInformation'] = this.memberInformation!.toJson(); @@ -60,13 +54,7 @@ class ListDoctorsClinic { late bool? isActive; late String? clinicName; - ListDoctorsClinic( - {this.setupID, - this.projectID, - this.doctorID, - this.clinicID, - this.isActive, - this.clinicName}); + ListDoctorsClinic({this.setupID, this.projectID, this.doctorID, this.clinicID, this.isActive, this.clinicName}); ListDoctorsClinic.fromJson(Map json) { setupID = json['SetupID']; diff --git a/lib/core/viewModel/authentication_view_model.dart b/lib/core/viewModel/authentication_view_model.dart index bf7a20ec..a6692563 100644 --- a/lib/core/viewModel/authentication_view_model.dart +++ b/lib/core/viewModel/authentication_view_model.dart @@ -56,8 +56,8 @@ class AuthenticationViewModel extends BaseViewModel { CheckActivationCodeForDoctorAppResponseModel get checkActivationCodeForDoctorAppRes => _authService.checkActivationCodeForDoctorAppRes; - late NewLoginInformationModel loggedUser; - late GetIMEIDetailsModel? user; + NewLoginInformationModel? loggedUser; + GetIMEIDetailsModel? user; UserModel userInfo = UserModel(); final LocalAuthentication auth = LocalAuthentication(); @@ -165,9 +165,9 @@ class AuthenticationViewModel extends BaseViewModel { int projectID = await sharedPref.getInt(PROJECT_ID); ActivationCodeModel activationCodeModel = ActivationCodeModel( facilityId: projectID, - memberID: loggedUser.listMemberInformation![0].memberID, - zipCode: loggedUser.zipCode, - mobileNumber: loggedUser.mobileNumber, + memberID: loggedUser!.listMemberInformation![0].memberID, + zipCode: loggedUser!.zipCode, + mobileNumber: loggedUser!.mobileNumber, otpSendType: authMethodType.getTypeIdService().toString(), password: password); await _authService.sendActivationCodeForDoctorApp(activationCodeModel); @@ -182,8 +182,8 @@ class AuthenticationViewModel extends BaseViewModel { Future checkActivationCodeForDoctorApp({required String activationCode}) async { setState(ViewState.BusyLocal); CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = new CheckActivationCodeRequestModel( - zipCode: loggedUser != null ? loggedUser.zipCode : user!.zipCode, - mobileNumber: loggedUser != null ? loggedUser.mobileNumber : user!.mobile, + zipCode: loggedUser != null ? loggedUser!.zipCode : user!.zipCode, + mobileNumber: loggedUser != null ? loggedUser!.mobileNumber : user!.mobile, projectID: await sharedPref.getInt(PROJECT_ID) != null ? await sharedPref.getInt(PROJECT_ID) : user!.projectID, logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID), activationCode: activationCode ?? '0000', diff --git a/lib/screens/auth/verification_methods_screen.dart b/lib/screens/auth/verification_methods_screen.dart index 94404bc1..03d6a6e6 100644 --- a/lib/screens/auth/verification_methods_screen.dart +++ b/lib/screens/auth/verification_methods_screen.dart @@ -47,7 +47,7 @@ class _VerificationMethodsScreenState extends State { late ProjectViewModel projectsProvider; bool isMoreOption = false; bool onlySMSBox = false; - late AuthMethodTypes fingerPrintBefore; + AuthMethodTypes? fingerPrintBefore; late AuthMethodTypes selectedOption; late AuthenticationViewModel authenticationViewModel; @@ -410,7 +410,7 @@ class _VerificationMethodsScreenState extends State { if (authMethodType == AuthMethodTypes.Fingerprint || authMethodType == AuthMethodTypes.FaceID) { fingerPrintBefore = authMethodType; } - this.selectedOption = fingerPrintBefore != null ? fingerPrintBefore : authMethodType; + this.selectedOption = (fingerPrintBefore != null ? fingerPrintBefore : authMethodType)!; switch (authMethodType) { case AuthMethodTypes.SMS: @@ -444,7 +444,7 @@ class _VerificationMethodsScreenState extends State { context, type, authenticationViewModel.loggedUser != null - ? authenticationViewModel.loggedUser.mobileNumber + ? authenticationViewModel.loggedUser!.mobileNumber : authenticationViewModel.user!.mobile, (value) { showDialog( diff --git a/lib/screens/home/home_page_card.dart b/lib/screens/home/home_page_card.dart index 383e7a9e..c4743f3b 100644 --- a/lib/screens/home/home_page_card.dart +++ b/lib/screens/home/home_page_card.dart @@ -15,14 +15,14 @@ class HomePageCard extends StatelessWidget { final bool hasBorder; final String? imageName; final Widget child; - final Function onTap; + final GestureTapCallback onTap; final Color color; final double opacity; final EdgeInsets margin; @override Widget build(BuildContext context) { return InkWell( - onTap: onTap(), + onTap: onTap, child: Container( width: 120, height: MediaQuery.of(context).orientation == Orientation.portrait ? 100 : 200, diff --git a/lib/screens/home/home_patient_card.dart b/lib/screens/home/home_patient_card.dart index 63b998bc..f0bee0cb 100644 --- a/lib/screens/home/home_patient_card.dart +++ b/lib/screens/home/home_patient_card.dart @@ -9,7 +9,7 @@ class HomePatientCard extends StatelessWidget { final Color backgroundIconColor; final String text; final Color textColor; - final Function onTap; + final GestureTapCallback onTap; HomePatientCard({ required this.backgroundColor, diff --git a/lib/screens/patients/out_patient/out_patient_screen.dart b/lib/screens/patients/out_patient/out_patient_screen.dart index bb211329..ad4c3fbf 100644 --- a/lib/screens/patients/out_patient/out_patient_screen.dart +++ b/lib/screens/patients/out_patient/out_patient_screen.dart @@ -68,7 +68,7 @@ class _OutPatientsScreenState extends State { List _times = []; int _activeLocation = 1; - late String patientType; + String? patientType; late String patientTypeTitle; var selectedFilter = 1; late String arrivalType; @@ -252,8 +252,8 @@ class _OutPatientsScreenState extends State { padding: EdgeInsets.all(8.0), child: PatientCard( patientInfo: model.filterData[index], - patientType: patientType, - arrivalType: arrivalType, + patientType: "1", + arrivalType: "1", isFromSearch: widget.isSearchAndOut, isInpatient: widget.isInpatient, onTap: () { diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 4f15871d..d83ea0ee 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -121,9 +121,9 @@ class _PrescriptionFormWidgetState extends State { bool visbiltySearch = true; final myController = TextEditingController(); - late DateTime selectedDate; - late int strengthChar; - late GetMedicationResponseModel _selectedMedication; + DateTime? selectedDate; + int? strengthChar; + GetMedicationResponseModel? _selectedMedication; GlobalKey key = new GlobalKey>(); TextEditingController drugIdController = TextEditingController(); @@ -358,7 +358,7 @@ class _PrescriptionFormWidgetState extends State { visbiltyPrescriptionForm = true; visbiltySearch = false; _selectedMedication = model.allMedicationList[index]; - uom = _selectedMedication.uom; + uom = _selectedMedication!.uom; }, ); }, @@ -417,7 +417,7 @@ class _PrescriptionFormWidgetState extends State { setState(() { strengthChar = value.length; }); - if (strengthChar >= 5) { + if (strengthChar! >= 5) { DrAppToastMsg.showErrorToast( TranslationBase.of(context).only5DigitsAllowedForStrength, ); @@ -483,7 +483,7 @@ class _PrescriptionFormWidgetState extends State { model.getBoxQuantity( freq: frequency['parameterCode'], duration: duration['id'], - itemCode: _selectedMedication.itemId!, + itemCode: _selectedMedication!.itemId!, strength: double.parse(strengthController.text)); return; @@ -577,7 +577,7 @@ class _PrescriptionFormWidgetState extends State { model.getBoxQuantity( freq: frequency['parameterCode'], duration: duration['id'], - itemCode: _selectedMedication.itemId!, + itemCode: _selectedMedication!.itemId!, strength: double.parse(strengthController.text), ); box = model.boxQuintity; @@ -661,7 +661,7 @@ class _PrescriptionFormWidgetState extends State { units != null && selectedDate != null && strengthController.text != "") { - if (_selectedMedication.isNarcotic == true) { + if (_selectedMedication!.isNarcotic == true) { DrAppToastMsg.showErrorToast(TranslationBase.of(context) .narcoticMedicineCanOnlyBePrescribedFromVida); Navigator.pop(context); @@ -922,7 +922,7 @@ class _PrescriptionFormWidgetState extends State { route: model.itemMedicineListRoute.length == 1 ? model.itemMedicineListRoute[0]['parameterCode'].toString() : route['parameterCode'].toString(), - drugId: _selectedMedication.itemId.toString(), + drugId: _selectedMedication!.itemId.toString(), strength: strengthController.text, indication: indicationController.text, instruction: instructionController.text, @@ -958,10 +958,10 @@ class _PrescriptionFormWidgetState extends State { } }); } - if (_selectedMedication.mediSpanGPICode != null) { + if (_selectedMedication!.mediSpanGPICode != null) { prescriptionDetails.add({ - 'DrugId': _selectedMedication.mediSpanGPICode, - 'DrugName': _selectedMedication.description, + 'DrugId': _selectedMedication!.mediSpanGPICode, + 'DrugName': _selectedMedication!.description, 'Dose': strengthController.text, 'DoseType': model.itemMedicineListUnit.length == 1 ? model.itemMedicineListUnit[0]['parameterCode'].toString() diff --git a/lib/screens/procedures/ExpansionProcedure.dart b/lib/screens/procedures/ExpansionProcedure.dart index c1901411..740ae8e6 100644 --- a/lib/screens/procedures/ExpansionProcedure.dart +++ b/lib/screens/procedures/ExpansionProcedure.dart @@ -15,10 +15,10 @@ class ExpansionProcedure extends StatefulWidget { final ProcedureViewModel model; final Function(ProcedureTempleteDetailsModel) removeFavProcedure; final Function(ProcedureTempleteDetailsModel) addFavProcedure; - final Function(ProcedureTempleteDetailsModel) selectProcedures; + final Function(ProcedureTempleteDetailsModel)? selectProcedures; - final bool Function(ProcedureTempleteModel) isEntityListSelected; - final bool Function(ProcedureTempleteDetailsModel) isEntityFavListSelected; + final bool Function(ProcedureTempleteModel)? isEntityListSelected; + final bool Function(ProcedureTempleteDetailsModel)? isEntityFavListSelected; final bool isProcedure; final ProcedureTempleteDetailsModel groupProcedures; @@ -28,9 +28,9 @@ class ExpansionProcedure extends StatefulWidget { required this.model, required this.removeFavProcedure, required this.addFavProcedure, - required this.selectProcedures, - required this.isEntityListSelected, - required this.isEntityFavListSelected, + this.selectProcedures, + this.isEntityListSelected, + this.isEntityFavListSelected, this.isProcedure = true, required this.groupProcedures}) : super(key: key); @@ -118,14 +118,14 @@ class _ExpansionProcedureState extends State { onTap: () { if (widget.isProcedure) { setState(() { - if (widget.isEntityFavListSelected(itemProcedure)) { + if (widget.isEntityFavListSelected!(itemProcedure)) { widget.removeFavProcedure(itemProcedure); } else { widget.addFavProcedure(itemProcedure); } }); } else { - widget.selectProcedures(itemProcedure); + widget.selectProcedures!(itemProcedure); } }, child: Container( @@ -140,11 +140,11 @@ class _ExpansionProcedureState extends State { padding: const EdgeInsets.symmetric(horizontal: 11), child: widget.isProcedure ? Checkbox( - value: widget.isEntityFavListSelected(itemProcedure), + value: widget.isEntityFavListSelected!(itemProcedure), activeColor: Color(0xffD02127), onChanged: (bool? newValue) { setState(() { - if (widget.isEntityFavListSelected(itemProcedure)) { + if (widget.isEntityFavListSelected!(itemProcedure)) { widget.removeFavProcedure(itemProcedure); } else { widget.addFavProcedure(itemProcedure); @@ -156,7 +156,7 @@ class _ExpansionProcedureState extends State { groupValue: widget.groupProcedures, activeColor: Color(0xffD02127), onChanged: (ProcedureTempleteDetailsModel? newValue) { - widget.selectProcedures(newValue!); + widget.selectProcedures!(newValue!); })), Expanded( child: Padding( diff --git a/lib/screens/procedures/ProcedureCard.dart b/lib/screens/procedures/ProcedureCard.dart index ef9478d5..f110f931 100644 --- a/lib/screens/procedures/ProcedureCard.dart +++ b/lib/screens/procedures/ProcedureCard.dart @@ -12,7 +12,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class ProcedureCard extends StatelessWidget { - final Function onTap; + final GestureTapCallback onTap; final EntityList entityList; final String? categoryName; final int categoryID; @@ -248,7 +248,7 @@ class ProcedureCard extends StatelessWidget { doctorID == entityList.doctorID) InkWell( child: Icon(DoctorApp.edit), - onTap: onTap(), + onTap: onTap, ) ], ), diff --git a/lib/widgets/patients/PatientCard.dart b/lib/widgets/patients/PatientCard.dart index e4673741..1ff05222 100644 --- a/lib/widgets/patients/PatientCard.dart +++ b/lib/widgets/patients/PatientCard.dart @@ -11,7 +11,7 @@ import 'package:flutter/material.dart'; class PatientCard extends StatelessWidget { final PatiantInformtion patientInfo; - final Function onTap; + final GestureTapCallback onTap; final String patientType; final String arrivalType; final bool isInpatient; @@ -451,7 +451,7 @@ class PatientCard extends StatelessWidget { : SizedBox() ], ), - onTap: onTap(), + onTap: onTap, )), )); }