Skip to content

feat: Add disabledPicker property to FormBuilderDateTimePicker #1497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

CesareIsHere
Copy link
Contributor

This PR adds support for the readOnly property to FormBuilderDateTimePicker, bringing it in line with other form builder fields and Flutter's native TextField behavior.

Changes Made

  • Added readOnly property to FormBuilderDateTimePicker constructor with default value false
  • Modified the onTap callback to conditionally prevent picker dialogs from opening when readOnly is true
  • Updated documentation for the new property

Behavior

When readOnly: true:

  • ✅ Field displays the current date/time value normally
  • ✅ Date/time picker dialogs do not open when tapping the field
  • ✅ Field maintains normal visual appearance (not grayed out like enabled: false)
  • ✅ Field remains focusable for accessibility
  • ✅ Value is still accessible for form submission and validation
  • ✅ Consistent with other FormBuilder fields API

Usage Example

FormBuilderDateTimePicker(
  name: 'created_date',
  readOnly: true,
  initialValue: DateTime.now(),
  decoration: InputDecoration(
    labelText: 'Creation Date',
    hintText: 'This field is read-only',
  ),
)

Use Cases

  • Displaying creation/modification timestamps
  • Showing calculated dates that shouldn't be modified
  • Form sections that are conditionally editable based on user permissions
  • Confirmation/review screens where data should be visible but not modifiable

Breaking Changes

None - this is a backward-compatible addition with a sensible default value.

@deandreamatias
Copy link
Collaborator

Nice! Is useful new use for property but I think that could use decoration.readonly for this propouse.

@CesareIsHere
Copy link
Contributor Author

@deandreamatias the problem with decoration.readOnly is that the field is always in readOnly because the value is insert through the date picker. The goal of this feat is to disable input using picker.

@deandreamatias
Copy link
Collaborator

@CesareIsHere so maybe need another name, to avoid confusion.
Something like disableOpenPicker or any else better

@CesareIsHere
Copy link
Contributor Author

@deandreamatias That sounds good, thank you!
I renamed it to disablePicker

Copy link

codecov bot commented Jun 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.88%. Comparing base (84dbb3f) to head (a4a8574).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1497   +/-   ##
=======================================
  Coverage   89.88%   89.88%           
=======================================
  Files          21       21           
  Lines         840      840           
=======================================
  Hits          755      755           
  Misses         85       85           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@deandreamatias deandreamatias changed the title feat: Add readOnly property to FormBuilderDateTimePicker feat: Add disabledPicker property to FormBuilderDateTimePicker Jun 25, 2025
@deandreamatias deandreamatias merged commit a0af924 into flutter-form-builder-ecosystem:main Jun 25, 2025
7 of 9 checks passed
@CesareIsHere CesareIsHere deleted the formbuilderdatetimepicker-add-readonly-parameter branch June 25, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants