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.
AnhDai317 (6c752b20) at 04 Mar 01:53
Fix ARB formatting and add future date/time validation strings
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
Form widget with a GlobalKey<FormState> to wrap the ListView._formKey.currentState!.validate().2. Error Messages & Localization (L10n)
add_baby.dart..arb files (en, ar, de, hi) to include the new keys (weightErrorG, babyWardNumber, etc.) and ensured all missing translations were filled..arb files.3. Code Style & Layout Fixes
{} to all single-line if statements in the range validators to maintain consistency with the rest of the codebase.VerticalSpace(height: 15) duplicates before the Birth Description section to clean up the form layout.4. Logic Improvements (in add_baby_bloc.dart)
emit outside of the for loop in the searchMotherInList method to prevent unnecessary multiple state emissions and potential UI lags.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
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!
AnhDai317 (5b255d42) at 28 Feb 04:53
fix: implement mentor feedback for form validation and localization
Thank you so much for the detailed review and for catching those edge cases! I have addressed all the issues you pointed out:
app_en.arb, app_de.arb, app_ar.arb, app_hi.arb), fixed the indentation inconsistencies, and ensured a trailing newline is present.RegExp(r'^[\p{L}\s]+$', unicode: true) to strictly prevent numbers or special characters while keeping it multilingually safe.lastDate bound in the DatePicker.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!
AnhDai317 (fc3056cd) at 26 Feb 11:22
fix: address PR review feedbacks regarding form validation and ARB ...
Hi @saptarshi, thank you for the detailed and constructive feedback! I have carefully addressed all 6 points you mentioned:
ListView in add_baby.dart with a Form widget and assigned a GlobalKey<FormState>._formKey.currentState!.validate() check is now correctly enforced inside the AddBabyButton.onPressed callback before any event dispatch.autovalidateMode: AutovalidateMode.onUserInteraction to all TextFormField widgets so the validation UI updates naturally as the user interacts.AppLocalizations.of(context) and updated the corresponding keys in all 4 .arb files (en, ar, de, hi).double.parse() with double.tryParse() for weight, length, and head circumference. The app no longer crashes when switching units with empty or invalid inputs.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.
AnhDai317 (11bfccef) at 25 Feb 16:17
fix: implement mentor feedback for form validation and localization
Hi team, I have updated the Add Baby form to resolve Issue #130.
Changes made:
TextField widgets to TextFormField to enable form validation.Fixes #130
AnhDai317 (500f0d46) at 25 Feb 02:24
feat: add input validation to Add Baby form. Fixes #130