From 1ba47515c680204b8411fdfe41438310affb2dfb Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 7 Sep 2021 14:23:04 +0300 Subject: [PATCH] changing list genrate to list builder --- .../prescription/prescriptions_page.dart | 61 ++++++++++--------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index f416db46..e7225e9a 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -162,38 +162,43 @@ class PrescriptionsPage extends StatelessWidget { // height: 12, // ), - ...List.generate( - model.medicationForInPatient.length, - (index) => InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: PrescriptionItemsInPatientPage( - prescriptionIndex: index, - prescriptions: model.medicationForInPatient[index], - patient: patient, - patientType: patientType, - arrivalType: arrivalType, - startOn: AppDateUtils.getDateTimeFromServerFormat( - model.medicationForInPatient[index].startDatetime, - ), - stopOn: AppDateUtils.getDateTimeFromServerFormat( - model.medicationForInPatient[index].stopDatetime, + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.medicationForInPatient.length, + itemBuilder: (context, index) { + //model.medicationForInPatient.length, + return InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionItemsInPatientPage( + prescriptionIndex: index, + prescriptions: model.medicationForInPatient[index], + patient: patient, + patientType: patientType, + arrivalType: arrivalType, + startOn: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].startDatetime, + ), + stopOn: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].stopDatetime, + ), ), ), ), + child: InPatientDoctorCard( + doctorName: model.medicationForInPatient[index].pHRItemDescription, + profileUrl: 'sss', + branch: 'hamza', + clinic: 'basheer', + isPrescriptions: true, + appointmentDate: AppDateUtils.getDateTimeFromServerFormat( + model.medicationForInPatient[index].prescriptionDatetime, ), - child: InPatientDoctorCard( - doctorName: model.medicationForInPatient[index].pHRItemDescription, - profileUrl: 'sss', - branch: 'hamza', - clinic: 'basheer', - isPrescriptions: true, - appointmentDate: AppDateUtils.getDateTimeFromServerFormat( - model.medicationForInPatient[index].prescriptionDatetime, - ), - createdBy: model.medicationForInPatient[index].createdBy.toString(), - ))), + createdBy: model.medicationForInPatient[index].createdBy.toString(), + )); + }), if (model.medicationForInPatient.length == 0) Center( child: Column(