From cb01308f96e05dad95e5db92e4fe1120f8ba34ec Mon Sep 17 00:00:00 2001 From: Aamir Date: Mon, 11 Dec 2023 16:33:41 +0300 Subject: [PATCH] Null Safety --- .../viewModel/authentication_view_model.dart | 4 +- .../patient_search_result_screen.dart | 66 ++++++++----------- .../patients/patient_card/PatientCard.dart | 4 +- .../app_text_field_custom_serach.dart | 2 +- 4 files changed, 33 insertions(+), 43 deletions(-) diff --git a/lib/core/viewModel/authentication_view_model.dart b/lib/core/viewModel/authentication_view_model.dart index 9111c416..8411b443 100644 --- a/lib/core/viewModel/authentication_view_model.dart +++ b/lib/core/viewModel/authentication_view_model.dart @@ -398,10 +398,10 @@ class AuthenticationViewModel extends BaseViewModel { /// logout function logout({bool isFromLogin = false}) async { localToken = ""; - String lang = await sharedPref.getString(APP_Language); + String? lang = await sharedPref.getString(APP_Language); await Utils.clearSharedPref(); doctorProfile = null; - sharedPref.setString(APP_Language, lang); + sharedPref.setString(APP_Language, lang ?? 'en'); deleteUser(); await getDeviceInfoFromFirebase(); this.isFromLogin = isFromLogin; diff --git a/lib/screens/patients/patient_search/patient_search_result_screen.dart b/lib/screens/patients/patient_search/patient_search_result_screen.dart index 2abfb1af..8447964e 100644 --- a/lib/screens/patients/patient_search/patient_search_result_screen.dart +++ b/lib/screens/patients/patient_search/patient_search_result_screen.dart @@ -27,28 +27,20 @@ class PatientsSearchResultScreen extends StatefulWidget { final String? searchKey; PatientsSearchResultScreen( - {this.selectedPatientType, - this.patientSearchRequestModel, - this.isSearchWithKeyInfo = true, - this.isSearch = false, - this.isInpatient = false, - this.searchKey, - this.isSearchAndOut = false}); + {this.selectedPatientType, this.patientSearchRequestModel, this.isSearchWithKeyInfo = true, this.isSearch = false, this.isInpatient = false, this.searchKey, this.isSearchAndOut = false}); @override - _PatientsSearchResultScreenState createState() => - _PatientsSearchResultScreenState(); + _PatientsSearchResultScreenState createState() => _PatientsSearchResultScreenState(); } -class _PatientsSearchResultScreenState - extends State { +class _PatientsSearchResultScreenState extends State { int? clinicId; AuthenticationViewModel authenticationViewModel = AuthenticationViewModel(); - String? patientType; + String patientType = ''; String? patientTypeTitle; var selectedFilter = 1; - String? arrivalType; + String arrivalType = ''; late ProjectViewModel projectsProvider; var isView; final _controller = TextEditingController(); @@ -60,12 +52,10 @@ class _PatientsSearchResultScreenState authenticationViewModel = Provider.of(context); return BaseView( onModelReady: (model) async { - if (!widget.isSearchWithKeyInfo && - widget.selectedPatientType == PatientType.OutPatient) { + if (!widget.isSearchWithKeyInfo && widget.selectedPatientType == PatientType.OutPatient) { await model.getOutPatient(widget.patientSearchRequestModel!); } else { - await model - .getPatientFileInformation(widget.patientSearchRequestModel!); + await model.getPatientFileInformation(widget.patientSearchRequestModel!); } }, builder: (_, model, w) => AppScaffold( @@ -89,9 +79,10 @@ class _PatientsSearchResultScreenState DoctorApp.filter_1, color: Colors.black, ), - iconSize: 20, onPressed: () { }, + iconSize: 20, onPressed: () {}, // padding: EdgeInsets.only(bottom: 30), - ), onFieldSubmitted: (){}, + ), + onFieldSubmitted: () {}, ), SizedBox( height: 10.0, @@ -101,8 +92,7 @@ class _PatientsSearchResultScreenState child: model.filterData.isEmpty ? Center( child: ErrorMessage( - error: TranslationBase.of(context) - .youDontHaveAnyPatient, + error: TranslationBase.of(context).youDontHaveAnyPatient, ), ) : ListView.builder( @@ -114,27 +104,27 @@ class _PatientsSearchResultScreenState padding: EdgeInsets.all(8.0), child: PatientCard( patientInfo: model.filterData[index], - patientType: patientType!, - arrivalType: arrivalType!, + patientType: patientType, + arrivalType: arrivalType, isFromSearch: widget.isSearchAndOut, isInpatient: widget.isInpatient, onTap: () { + print("TODO change the parameter to daynamic"); + print("TODO change the parameter to daynamic"); + print("TODO change the parameter to daynamic"); + print("TODO change the parameter to daynamic"); + print("TODO change the parameter to daynamic"); // TODO change the parameter to daynamic - Navigator.of(context).pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": model.filterData[index], - "patientType": "1", - "from": widget - .patientSearchRequestModel!.from, - "to": widget - .patientSearchRequestModel!.from, - "isSearch": widget.isSearch, - "isInpatient": widget.isInpatient, - "arrivalType": "7", - "isSearchAndOut": - widget.isSearchAndOut, - }); + Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { + "patient": model.filterData[index], + "patientType": "1", + "from": widget.patientSearchRequestModel!.from, + "to": widget.patientSearchRequestModel!.from, + "isSearch": widget.isSearch, + "isInpatient": widget.isInpatient, + "arrivalType": "7", + "isSearchAndOut": widget.isSearchAndOut, + }); }, // isFromSearch: widget.isSearch, ), diff --git a/lib/widgets/patients/patient_card/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart index d8b059b6..fa167fff 100644 --- a/lib/widgets/patients/patient_card/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -18,7 +18,7 @@ import 'ShowTimer.dart'; class PatientCard extends StatelessWidget { final PatiantInformtion? patientInfo; - final Function()? onTap; + final Function() onTap; final String patientType; final String arrivalType; final bool isInpatient; @@ -451,7 +451,7 @@ class PatientCard extends StatelessWidget { : SizedBox() ], ), - onTap: onTap!(), + onTap: onTap, )), )); } diff --git a/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart b/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart index 2995ddd8..025350b1 100644 --- a/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart +++ b/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart @@ -63,7 +63,7 @@ class AppTextFieldCustomSearch extends StatelessWidget { onChangeFun(val!); }, onFieldSubmitted: () { - onFieldSubmitted(); + onFieldSubmitted; }, validationError: validationError, onClick: () {},