diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 68d4e633..b25d3928 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -360,12 +360,12 @@ class _PrescriptionFormWidgetState extends State { .width * 0.550, child: TextFields( - // inputFormatters: [ - // LengthLimitingTextInputFormatter( - // 4), - // WhitelistingTextInputFormatter - // .digitsOnly - // ], + inputFormatters: [ + LengthLimitingTextInputFormatter( + 4), + // WhitelistingTextInputFormatter + // .digitsOnly + ], hintText: TranslationBase.of(context) .strength, diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart index c50059f2..ace71350 100644 --- a/lib/screens/prescription/update_prescription_form.dart +++ b/lib/screens/prescription/update_prescription_form.dart @@ -115,7 +115,7 @@ class _UpdatePrescriptionFormState extends State { (BuildContext context, StateSetter setState /*You can rename this!*/) { return BaseView( onModelReady: (model) async { - await model.getMedicationList(); + //await model.getMedicationList(); await model.getMedicationStrength(); await model.getMedicationDuration(); await model.getMedicationRoute(); @@ -257,14 +257,17 @@ class _UpdatePrescriptionFormState extends State { inputFormatters: [ LengthLimitingTextInputFormatter( 4), - WhitelistingTextInputFormatter - .digitsOnly + // WhitelistingTextInputFormatter + // .digitsOnly ], + hintText: widget.doseStreangth, fontSize: 15.0, controller: strengthController, - keyboardType: - TextInputType.number, + keyboardType: TextInputType + .numberWithOptions( + decimal: true, + ), onChanged: (String value) { setState(() { strengthChar = value.length; @@ -700,6 +703,27 @@ class _UpdatePrescriptionFormState extends State { title: 'update prescription' .toUpperCase(), onPressed: () { + if (int.parse( + strengthController.text) > + 1000) { + DrAppToastMsg.showErrorToast( + "1000 is the MAX for the strength"); + return; + } + if (int.parse(strengthController + .text) == + 0) { + DrAppToastMsg.showErrorToast( + "Streangth can't be zero"); + return; + } + if (strengthController + .text.length > + 4) { + DrAppToastMsg.showErrorToast( + "Streangth can't be zero"); + return; + } updatePrescription( newStartDate: selectedDate, newDoseStreangth: