CupertinoDatePicker
An iOS-styled date picker.
Inherits: LayoutControl
Properties
bgcolor- The background color of this date picker.date_order- The order in which the columns inside this picker are displayed.date_picker_mode- The mode of the date picker.first_date- The earliest allowable date that the user can select.item_extent- The uniform height of all children.last_date- The latest allowable date that the user can select.locale- The locale for this date picker.maximum_year- Maximum year to which the picker can be scrolled when in flet.CupertinoDatePickerMode.DATE mode.minimum_year- Minimum year to which the picker can be scrolled when in flet.CupertinoDatePickerMode.DATE mode.minute_interval- The granularity of the minutes spinner, if it is shown in the current date_picker_mode.show_day_of_week- Whether to show day of week alongside day.use_24h_format- Whether to use the 24-hour time format.value- The initial date and/or time of the picker.
Events
on_change- Called when the selected date and/or time changes.
Examples
Basic Example
from datetime import datetime
import flet as ft
def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
message = ft.Text("Chosen Time:")
def handle_date_change(e: ft.Event[ft.CupertinoDatePicker]):
message.value = f"Chosen Date: {e.control.value.strftime('%Y-%m-%d %H:%M %p')}"
cupertino_date_picker = ft.CupertinoDatePicker(
value=datetime.now(),
date_picker_mode=ft.CupertinoDatePickerMode.DATE_AND_TIME,
on_change=handle_date_change,
)
page.add(
ft.SafeArea(
content=ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
controls=[
ft.CupertinoFilledButton(
on_click=lambda _: page.show_dialog(
ft.CupertinoBottomSheet(
height=216,
padding=ft.Padding.only(top=6),
content=cupertino_date_picker,
)
),
content="Open CupertinoDatePicker",
),
message,
],
),
)
)
if __name__ == "__main__":
ft.run(main)

Properties
bgcolorclass-attributeinstance-attribute
bgcolor: Optional[ColorValue] = NoneThe background color of this date picker.
date_orderclass-attributeinstance-attribute
date_order: Optional[CupertinoDatePickerDateOrder] = NoneThe order in which the columns inside this picker are displayed.
The final order in which the columns are displayed is also influenced by
the date_picker_mode. For example, if date_picker_mode is
flet.CupertinoDatePickerMode.MONTH_YEAR
both flet.CupertinoDatePickerDateOrder.DAY_MONTH_YEAR and
flet.CupertinoDatePickerDateOrder.MONTH_DAY_YEAR will result
in the month|year order.
date_picker_modeclass-attributeinstance-attribute
date_picker_mode: CupertinoDatePickerMode = CupertinoDatePickerMode.DATE_AND_TIMEThe mode of the date picker.
first_dateclass-attributeinstance-attribute
first_date: Optional[DateTimeValue] = NoneThe earliest allowable date that the user can select.
- If set to
None(the default), there is no lower date limit. - When not
None, one can still scroll the picker to dates earlier thanfirst_date, with the exception that the on_change will not be called. Once let go, the picker will scroll back tofirst_date.
In flet.CupertinoDatePickerMode.TIME mode, a time becomes unselectable
if the datetime produced by combining that particular time and the date part of
value is earlier than last_date. So typically, first_date needs
to be set to a datetime that is on the same date as value.
item_extentclass-attributeinstance-attribute
item_extent: Number = 32.0The uniform height of all children.
Raises:
- ValueError - If it is not strictly greater than
0.
last_dateclass-attributeinstance-attribute
last_date: Optional[DateTimeValue] = NoneThe latest allowable date that the user can select.
- If set to
None(the default), there is no upper date limit. - When not
None, one can still scroll the picker to dates later thanlast_date, with the exception that the on_change will not be called. Once let go, the picker will scroll back tolast_date.
In flet.CupertinoDatePickerMode.TIME mode, a time becomes unselectable
if the datetime produced by combining that particular time and the date part
of value is later than last_date. So typically, last_date needs
to be set to a datetime that is on the same date as value.
localeclass-attributeinstance-attribute
locale: Optional[Locale] = NoneThe locale for this date picker. It is intended for rare cases where this control should be localized differently from the rest of the page.
- The locale must be supported by Flutter's global localization delegates; otherwise the override is ignored and the control uses the page or system locale.
- If
None(the default), the page or system locale is used.
maximum_yearclass-attributeinstance-attribute
maximum_year: Optional[int] = NoneMaximum year to which the picker can be scrolled when in flet.CupertinoDatePickerMode.DATE mode.
Defaults to None - no limit.
Raises:
- ValueError - If it is less than value year.
minimum_yearclass-attributeinstance-attribute
minimum_year: int = 1Minimum year to which the picker can be scrolled when in flet.CupertinoDatePickerMode.DATE mode.
Raises:
- ValueError - If it is greater than value year.
minute_intervalclass-attributeinstance-attribute
minute_interval: Annotated[int, V.gt(0), V.factor_of(60)] = 1The granularity of the minutes spinner, if it is shown in the current date_picker_mode.
Raises:
- ValueError - If it is not strictly greater than
0. - ValueError - If it is not a factor of
60.
show_day_of_weekclass-attributeinstance-attribute
show_day_of_week: bool = FalseWhether to show day of week alongside day.
Raises:
- ValueError - If it is set when date_picker_mode is not flet.CupertinoDatePickerMode.DATE.
use_24h_formatclass-attributeinstance-attribute
use_24h_format: bool = FalseWhether to use the 24-hour time format.
If False, the 12-hour time format is used.
valueclass-attributeinstance-attribute
value: DateTimeValue = field(default_factory=(lambda: datetime.now()))The initial date and/or time of the picker.
Defaults to the present date and time.
Raises:
- ValueError - If it is not greater than or equal to first_date, when first_date is set.
- ValueError - If it is not less than or equal to last_date, when last_date is set.
- ValueError - If its year is not greater than or equal to minimum_year, when date_picker_mode is flet.CupertinoDatePickerMode.DATE or flet.CupertinoDatePickerMode.MONTH_YEAR.
- ValueError - If its year is not less than or equal to maximum_year, when maximum_year is set.
- ValueError - If its minute is not a multiple of minute_interval.
Events
on_changeclass-attributeinstance-attribute
on_change: Optional[ControlEventHandler[CupertinoDatePicker]] = NoneCalled when the selected date and/or time changes.
Will not be called if the new selected value is not valid, or is not in the range of first_date and last_date.