AnhDai317 activity https://gitlab.com/AnhDai317 2026-03-04T01:55:16Z tag:gitlab.com,2026-03-04:5164205042 AnhDai317 commented on merge request !104 at LibreHealth / LibreHealth Incubating Projects / Mobile Helping Babies Survive (mHBS) / NeoRoo 2026-03-04T01:55:16Z AnhDai317 AnhDai317

Hi @saptarshi Purkayastha, thank you for the thorough review and for flagging these issues.

Here is a summary of what was fixed:

Issue 1 — Duplicate AddBaby class definition The MR had inadvertently added a full class AddBaby extends StatefulWidget definition (~210 lines, including _formKey, all controllers, the Form wrapper, and a complete build method) inside add_baby_input.dart. Since add_baby.dart already defines AddBaby and also imports add_baby_input.dart, this caused a duplicate class conflict at compile time. The fix was to remove the entire duplicate AddBaby definition from add_baby_input.dart, keeping it solely in add_baby.dart where it belongs. add_baby_input.dart retains only the reusable input widget classes it is meant to expose.

Issue 2 — Form.of(context)?.validate() is a silent no-op inside dialog/picker contexts Since showDialog, showDatePicker, and showTimePicker each push a new route via the Navigator, they create an independent overlay widget tree with no Form ancestor. As a result, Form.of(context) returned null in all three callbacks and .validate() never actually executed — meaning the mother name, birth date, and birth time fields were never re-validated after selection. Fix: _formKey (GlobalKey) is now passed down as a required parameter to AddBabyMothersName, AddBabyBirthDate, and AddBabyBirthTime. After a selection is confirmed, the code calls formKey.currentState?.validate() instead, which correctly reaches the Form in the parent widget tree regardless of where the callback executes. In the mother picker dialog, the validate call is also moved to after Navigator.pop(context) so it triggers on the main screen rather than while the dialog is still open.

Issue 3 — Generic "Invalid Input" message is not appropriate for a medical form In a neonatal care context, clinicians need actionable, specific feedback. Returning a generic "Invalid Input" when a future date or time is selected does not clearly communicate the constraint being violated. Fix: Two new localization keys were added across all four locale files (EN, AR, DE, HI):

birthDateCannotBeInFuture — shown when the selected birth date is after today birthTimeCannotBeInFuture — shown when today is selected but the time exceeds the current time

The existing invalidInput key is intentionally kept for the catch branch in the date validator, since a malformed date string is a system-level error rather than a clinical constraint violation.

Please let me know if any further changes are needed.

tag:gitlab.com,2026-03-04:5164201380 AnhDai317 pushed to project branch master at AnhDai317 / NeoRoo 2026-03-04T01:53:02Z AnhDai317 AnhDai317

AnhDai317 (6c752b20) at 04 Mar 01:53

Fix ARB formatting and add future date/time validation strings

tag:gitlab.com,2026-02-28:5152783874 AnhDai317 commented on merge request !104 at LibreHealth / LibreHealth Incubating Projects / Mobile Helping Babies Survive (mHBS) / NeoRoo 2026-02-28T04:54:51Z AnhDai317 AnhDai317

Thanks @saptarshi for the detailed feedback and guidance! I have addressed all your comments and made further improvements to ensure the form meets all acceptance criteria.

Here is the summary of the updates in this MR:

1. Form Validation & Medical Ranges

  • Added a Form widget with a GlobalKey<FormState> to wrap the ListView.
  • Prevented form submission if validation fails by wrapping the submit event with _formKey.currentState!.validate().
  • Corrected the validation ranges to meet strict medical criteria: Weight (500g - 6000g), Body Length (25cm - 60cm), and Head Circumference (20cm - 45cm) along with their respective converted limits for lbs and inch.

2. Error Messages & Localization (L10n)

  • Replaced generic "Invalid Input" with specific, localized range error messages (e.g., "Weight must be between 500g and 6000g").
  • Removed hardcoded English strings for Baby Ward Number and Baby Crib Number in add_baby.dart.
  • Synchronized all 4 .arb files (en, ar, de, hi) to include the new keys (weightErrorG, babyWardNumber, etc.) and ensured all missing translations were filled.
  • Added missing trailing newlines to the end of all .arb files.

3. Code Style & Layout Fixes

  • Added curly braces {} to all single-line if statements in the range validators to maintain consistency with the rest of the codebase.
  • Removed the consecutive VerticalSpace(height: 15) duplicates before the Birth Description section to clean up the form layout.

4. Logic Improvements (in add_baby_bloc.dart)

  • Moved the emit outside of the for loop in the searchMotherInList method to prevent unnecessary multiple state emissions and potential UI lags.
  • Removed birthNotes from the .isEmpty check in the addBaby event handler, as it is an optional field and was previously blocking form submission when left empty.

5. A quick note regarding l10n configuration

  • I noticed that the localization config file in the project root is currently named l10.yaml. Because it's missing the 'n', the flutter gen-l10n command ignores this file and defaults to generating the code into a synthetic package (inside .dart_tool/) instead of our target lib/l10n/ directory. I had to manually point the command to our directories to generate the files correctly this time. Could you take a look to see if it was a typo for l10n.yaml? If so, we might want to rename it globally so that future code generation runs smoothly for everyone.

Please let me know if there is anything else I should adjust!

tag:gitlab.com,2026-02-28:5152782564 AnhDai317 pushed to project branch master at AnhDai317 / NeoRoo 2026-02-28T04:53:12Z AnhDai317 AnhDai317

AnhDai317 (5b255d42) at 28 Feb 04:53

fix: implement mentor feedback for form validation and localization

tag:gitlab.com,2026-02-26:5145763359 AnhDai317 commented on merge request !104 at LibreHealth / LibreHealth Incubating Projects / Mobile Helping Babies Survive (mHBS) / NeoRoo 2026-02-26T11:25:08Z AnhDai317 AnhDai317

Thank you so much for the detailed review and for catching those edge cases! I have addressed all the issues you pointed out:

  1. ARB Files: Removed all duplicate entries across all language files (app_en.arb, app_de.arb, app_ar.arb, app_hi.arb), fixed the indentation inconsistencies, and ensured a trailing newline is present.
  2. Mother Name Validation: Implemented an alphabetic regex validation RegExp(r'^[\p{L}\s]+$', unicode: true) to strictly prevent numbers or special characters while keeping it multilingually safe.
  3. Future Date & Time Prevention: Updated the validator logic to strictly prevent any future dates AND future times (if today is selected) from passing validation, alongside fixing the lastDate bound in the DatePicker.
  4. Clinical Range Validations: Added clinical range validations for Birth Weight (e.g., 200g - 6000g). Additionally, since you mentioned the clinical importance of neonatal data, I proactively added similar realistic medical range constraints for Body Length and Head Circumference as well.
  5. Birth Description: Migrated the widget from TextField to TextFormField and added the required field validator.

The code has been pushed. Please let me know if everything looks good or if there are any other modifications needed!

tag:gitlab.com,2026-02-26:5145753573 AnhDai317 pushed to project branch master at AnhDai317 / NeoRoo 2026-02-26T11:22:39Z AnhDai317 AnhDai317

AnhDai317 (fc3056cd) at 26 Feb 11:22

fix: address PR review feedbacks regarding form validation and ARB ...

tag:gitlab.com,2026-02-25:5142519845 AnhDai317 commented on merge request !104 at LibreHealth / LibreHealth Incubating Projects / Mobile Helping Babies Survive (mHBS) / NeoRoo 2026-02-25T16:22:05Z AnhDai317 AnhDai317

Hi @saptarshi, thank you for the detailed and constructive feedback! I have carefully addressed all 6 points you mentioned:

  1. Missing Form Widget: Wrapped the main ListView in add_baby.dart with a Form widget and assigned a GlobalKey<FormState>.
  2. Validation Trigger: The _formKey.currentState!.validate() check is now correctly enforced inside the AddBabyButton.onPressed callback before any event dispatch.
  3. AutovalidateMode: Added autovalidateMode: AutovalidateMode.onUserInteraction to all TextFormField widgets so the validation UI updates naturally as the user interacts.
  4. Hard-coded Strings (Localization): Removed all hard-coded English strings. Replaced them with AppLocalizations.of(context) and updated the corresponding keys in all 4 .arb files (en, ar, de, hi).
  5. Unit Conversion Crash Prevention: Replaced double.parse() with double.tryParse() for weight, length, and head circumference. The app no longer crashes when switching units with empty or invalid inputs.
  6. Validation UI on Locked Fields: Changed enabled: false to readOnly: true for Mother's Name, Birth Date, and Birth Time. This ensures the red error border is visible when validation fails, while still preventing manual keyboard input.

I have manually tested the flow on my device, and everything works smoothly. Please see the attached screenshots for the validation UI.

image.png

tag:gitlab.com,2026-02-25:5142500509 AnhDai317 pushed to project branch master at AnhDai317 / NeoRoo 2026-02-25T16:17:50Z AnhDai317 AnhDai317

AnhDai317 (11bfccef) at 25 Feb 16:17

fix: implement mentor feedback for form validation and localization

tag:gitlab.com,2026-02-25:5139537060 AnhDai317 opened merge request !104: Resolve #130: Add input validation to Add Baby form at LibreHealth / LibreHealth Incubating Projects / Mobile Helping Ba... 2026-02-25T02:26:56Z AnhDai317 AnhDai317

Hi team, I have updated the Add Baby form to resolve Issue #130.

Changes made:

  • Migrated TextField widgets to TextFormField to enable form validation.
  • Added validation logic for required fields (Mother Name, Birth Date, Birth Time, Parent Group, Caregiver Group, Crib Number).
  • Added numeric validation (must be valid numbers > 0) for Birth Weight, Body Length, and Head Circumference.

Fixes #130

tag:gitlab.com,2026-02-25:5139533346 AnhDai317 pushed to project branch master at AnhDai317 / NeoRoo 2026-02-25T02:24:16Z AnhDai317 AnhDai317

AnhDai317 (500f0d46) at 25 Feb 02:24

feat: add input validation to Add Baby form. Fixes #130

tag:gitlab.com,2026-02-23:5130582295 AnhDai317 created project AnhDai317 / NeoRoo 2026-02-23T04:46:24Z AnhDai317 AnhDai317