Skip to content

Replace FTimeField/FDateField format DateFormat with callback#966

Merged
Pante merged 2 commits into
mainfrom
format-callback-date-time-fields
Apr 11, 2026
Merged

Replace FTimeField/FDateField format DateFormat with callback#966
Pante merged 2 commits into
mainfrom
format-callback-date-time-fields

Conversation

@Pante

@Pante Pante commented Apr 11, 2026

Copy link
Copy Markdown
Member

Describe the changes

  • Change FTimeField.picker(format: ...) and FDateField.calendar(format: ...) from DateFormat? to String Function(BuildContext, FTime/DateTime, DateFormat) — the callback receives the locale-aware default DateFormat so callers can compose or fall back to it.
  • Add FTimeField.defaultFormat and FDateField.defaultFormat static functions used as the new non-nullable defaults (mirrors FDateTimePicker.defaultDateBuilder / FDateField.defaultIconBuilder).
  • Update existing custom format tests, docs_snippets usages, and CHANGELOG.

Checklist

  • I have read the CONTRIBUTING.md.
  • I have included the relevant unit/golden tests.
  • I have included the relevant samples.
  • I have updated the documentation accordingly.
  • I have added the required flutters_hook for widget controllers.
  • I have updated the CHANGELOG.md if necessary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 11, 2026 15:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates FTimeField.picker(format: ...) and FDateField.calendar(format: ...) to accept a formatting callback instead of a DateFormat?, enabling callers to compose/customize output while receiving the locale-aware default DateFormat.

Changes:

  • Introduce FTimeField.defaultFormat / FDateField.defaultFormat as new defaults for the formatter callback.
  • Update picker/calendar implementations to call the formatter callback with the computed locale-aware DateFormat.
  • Update tests, docs snippets, and CHANGELOG for the breaking API change.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
forui/lib/src/widgets/time_field/time_field.dart Adds defaultFormat and changes picker factory format parameter type to a callback.
forui/lib/src/widgets/time_field/picker/picker_time_field.dart Switches internal formatting logic to call the callback (defaulting to FTimeField.defaultFormat).
forui/lib/src/widgets/date_field/date_field.dart Adds defaultFormat and changes calendar factory format parameter type to a callback.
forui/lib/src/widgets/date_field/calendar/calendar_date_field.dart Switches internal formatting logic to call the callback (defaulting to FDateField.defaultFormat).
forui/test/src/widgets/time_field/picker/picker_time_field_test.dart Updates the “custom format” test to the new callback API.
forui/test/src/widgets/date_field/calendar/calendar_date_field_test.dart Updates the “custom format” test to the new callback API.
docs_snippets/lib/usages/widgets/time_field.dart Updates snippet to use FTimeField.defaultFormat and removes intl import.
docs_snippets/lib/usages/widgets/date_field.dart Updates snippet to use FDateField.defaultFormat.
forui/CHANGELOG.md Documents the breaking change and the new default formatter helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread forui/lib/src/widgets/time_field/time_field.dart
Comment thread forui/lib/src/widgets/time_field/time_field.dart
Comment thread forui/lib/src/widgets/date_field/date_field.dart
Comment thread forui/lib/src/widgets/date_field/date_field.dart
@auto-maid

auto-maid Bot commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Documentation Preview

Latest Commit SHA 497eba1
Preview URL https://4b2f93dd-forui-docs-dev.duobase.workers.dev/docs

You're seeing this because the docs/samples were updated.

@Pante Pante merged commit da0a9cc into main Apr 11, 2026
20 checks passed
@Pante Pante deleted the format-callback-date-time-fields branch April 11, 2026 15:35
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