CNDatePicker class
A Cupertino-native date and time picker rendered by the host platform.
On iOS 26+ this embeds a UIDatePicker, and on every macOS an
NSDatePicker, through a platform view. Below iOS 26 and on other
platforms it falls back to CupertinoDatePicker: as wheels for
CNDatePickerStyle.wheels and CNDatePickerStyle.inline, and for
CNDatePickerStyle.compact as a pill that opens one in a popup.
Time zones
The picker shows and edits the wall-clock fields of value in the zone of
value: a local DateTime in the device's time zone, a UTC one
(DateTime.utc) in UTC. onChanged returns a DateTime in that same
zone, so DateTime.utc(2026, 11, 3) shows November 3 everywhere and
stays UTC. minimumDate and maximumDate are compared as instants,
whatever their zone.
Size
The compact pill and the wheels have the size the platform gives them; the pill's width follows the value. An inline calendar fills the width it is given, and its height follows that width; should a UIKit version change it with the shown month's week rows, that is followed too. The native view reports its size and this widget takes it, so the picker can go in a Row or a Column without a fixed size. A compact picker in a box wider than its pill, such as a ListView row, sits at the start of it.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CNDatePicker
- Available extensions
Constructors
-
CNDatePicker({Key? key, required DateTime value, required ValueChanged<
DateTime> onChanged, CNDatePickerMode mode = CNDatePickerMode.date, CNDatePickerStyle style = CNDatePickerStyle.automatic, DateTime? minimumDate, DateTime? maximumDate, int minuteInterval = 1, Color? tint, bool enabled = true, Locale? locale, String? semanticLabel, bool autoHideOnModal = true}) -
Creates a Cupertino-native date picker.
const
Properties
- autoHideOnModal → bool
-
When true (default), destroys the native picker's PlatformView while a
modal sheet is presented above this widget's host route. Prevents the
iOS hybrid-composition z-order bleed (Issue #53) where the host-page
PlatformView's pixels leak through a sheet that also contains a
PlatformView (CN-widget). Requires
CNTabBarRouteObserver()to be registered in the app'snavigatorObservers. No effect on non-iOS or iOS < 26 (Flutter fallback path).final - enabled → bool
-
Whether the user can change the value.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- locale → Locale?
-
The locale the native picker formats in: month names, the order of the
fields, and 12- or 24-hour time.
final
- maximumDate → DateTime?
-
The latest value the user can pick, or null for no limit.
final
- minimumDate → DateTime?
-
The earliest value the user can pick, or null for no limit.
final
- minuteInterval → int
-
The step of the minute wheel or field, from 1 to 30. It must divide 60.
final
- mode → CNDatePickerMode
-
What the picker lets the user pick.
final
-
onChanged
→ ValueChanged<
DateTime> -
Called when the user changes the value, with the new value in the zone
of value.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
What VoiceOver reads for the picker.
final
- style → CNDatePickerStyle
-
How the picker is drawn.
final
- tint → Color?
-
Accent color of the picker: the selected day, the open pill and the
calendar's arrows. Defaults to the theme's primary color.
final
- value → DateTime
-
The selected date and time.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CNDatePicker> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
liquidGlass(
{CNGlassEffect effect = CNGlassEffect.regular, CNGlassEffectShape shape = CNGlassEffectShape.capsule, double? cornerRadius, Color? tint, bool interactive = false}) → Widget -
Available on Widget, provided by the LiquidGlassExtension extension
Applies a Liquid Glass effect to this widget. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited