Skip to main content

Examples

Basic date field exampleBasic date field example
NeoDateField(
  dateString: dateString.value, // Using hooks
  onSubmitted: (value) {
    dateString.value = value;
  },
),

Properties

Required

dateString
String?
required
The current date string value in DD-MM-YYYY format. Can be partial during input but should be complete for display. Use null or empty string to clear the field.
onSubmitted
ValueChanged<String?>
required
Callback triggered when user completes editing (all segments filled or Enter pressed). Receives the normalized date string in DD-MM-YYYY format, or null when the field is cleared or contains invalid input.

Content

label
String?
Optional label text displayed above the date field.
description
String?
Optional helper text displayed below the field. Hidden when errorText is present.

State

errorText
String?
Error message displayed below the field. When present, shows error state with danger-colored border and replaces the description text.
isEnabled
bool
default:"true"
Controls whether the field accepts input and focus. When disabled, the field appears dimmed and prevents all interaction.
focusNode
FocusNode
Focus node for managing focus state programmatically. When not provided, the widget creates its own internal focus node.
onBlur
VoidCallback
Callback function called when the field loses focus. Useful for explicit blur event handling.
showClearButton
bool
default:"false"
Whether to show a clear button (x) that allows users to quickly clear the date field content.

Input Behavior

Value Clamping

  • Typing: Days clamped to 1-31, months to 1-12, years to 1-9999 regardless of context
  • Arrow keys: Context-aware clamping (e.g., day respects actual month/year if entered)
  • Why different?: Safety in high-stake applications - typing “31-02” shows the invalid state instead of silently auto-correcting

Auto-Advance

  • Day: Advances when typing ≥ 4 (e.g., “4” becomes “04” and advances)
  • Month: Advances when typing ≥ 2 (e.g., “2” becomes “02” and advances)
  • Year: Submits when 4 digits entered
  • Arrow keys: Move between segments or increment/decrement values
  • Tab: Standard focus navigation
  • Click: Jump to any segment and select all content

Best Practices

  • Validation: Use NeoDateValidator in onSubmitted for comprehensive validation
  • Width constraints: Wrap in SizedBox, Expanded, or ConstrainedBox to prevent layout issues
  • Error handling: Clear errorText and update dateString in onSubmitted for smooth UX

Integration Notes

  • Submission-based: Calls onSubmitted when complete (all segments filled, Enter pressed, or focus lost)
Last modified on January 21, 2026