Skip to content

feat: #1311 add allowClear and clearIcon to FormBuilderDateTimePicker#1505

Closed
majumdersubhanu wants to merge 1 commit intoflutter-form-builder-ecosystem:mainfrom
majumdersubhanu:neel-dev
Closed

feat: #1311 add allowClear and clearIcon to FormBuilderDateTimePicker#1505
majumdersubhanu wants to merge 1 commit intoflutter-form-builder-ecosystem:mainfrom
majumdersubhanu:neel-dev

Conversation

@majumdersubhanu
Copy link
Copy Markdown

@majumdersubhanu majumdersubhanu commented Apr 14, 2026

Connection with issue(s)

Close #1311

Solution description

Added allowClear property to FormBuilderDateTimePicker also builds upon the default input decoration.

@override
InputDecoration get decoration => widget.allowClear
    ? super.decoration.copyWith(
        suffix: value == null
            ? null
            : IconButton(
                padding: EdgeInsets.zero,
                constraints: const BoxConstraints(
                  maxWidth: 24,
                  maxHeight: 24,
                ),
                onPressed: () {
                  focus();
                  didChange(null);
                },
                icon: widget.clearIcon ?? const Icon(Icons.clear),
              ),
      )
    : super.decoration;

To use the new property

FormBuilderDateTimePicker(
  name: 'date',
  initialEntryMode: DatePickerEntryMode.calendar,
  initialValue: DateTime.now(),
  inputType: InputType.both,
  decoration: InputDecoration(
    labelText: 'Appointment Time',
    // TODO: use allowClear property to automatically perform this action.
    // suffixIcon: IconButton(
    //   icon: const Icon(Icons.close),
    //   onPressed: () {
    //     _formKey.currentState!.fields['date']?.didChange(null);
    //   },
    // ),
  ),
  initialTime: const TimeOfDay(hour: 8, minute: 0),
  // locale: const Locale.fromSubtags(languageCode: 'fr'),
  allowClear: true,
  // TODO: use any icon of choice or default one
  clearIcon: Icon(Icons.clear),
)

Screenshots or Videos

Screenshot 2026-04-14 144529

As you can see the x icon doesn't appear when the field is empty

image

The x icon appears ONLY when date and time are both selected, and also not selecting time leads to empty value in the field

To Do

  • Read contributing guide
  • Check the original issue to confirm it is fully satisfied
  • Add solution description to help guide reviewers
  • Add unit test to verify new or fixed behaviour
  • If apply, add documentation to code properties and package readme

@majumdersubhanu majumdersubhanu changed the title feat: add allowClear and clearIcon to FormBuilderDateTimePicker feat: #1311 add allowClear and clearIcon to FormBuilderDateTimePicker Apr 14, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.40%. Comparing base (bff073a) to head (9e160ad).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1505      +/-   ##
==========================================
+ Coverage   91.06%   91.40%   +0.33%     
==========================================
  Files          21       21              
  Lines         851      861      +10     
==========================================
+ Hits          775      787      +12     
+ Misses         76       74       -2     

☔ 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.

chore: add tests for FormBuilderDateTimePicker

chore: apply dart fix and format on codebase
@majumdersubhanu
Copy link
Copy Markdown
Author

Full disclosure this is my first OSS contribution ever, and feedback is greatly appreciated.

@majumdersubhanu majumdersubhanu deleted the neel-dev branch April 14, 2026 10:59
@majumdersubhanu majumdersubhanu restored the neel-dev branch April 14, 2026 10:59
@deandreamatias
Copy link
Copy Markdown
Collaborator

Sorry but this isn't a priority right now. See details on #1293

@majumdersubhanu majumdersubhanu deleted the neel-dev branch April 14, 2026 11:21
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.

FormBuilderDateTimePicker: Add allowClear parameter like what is available for FormBuilderDateRangePicker

2 participants