Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    iOS-style elements (Cupertino)

    Elements that look like native iOS controls: buttons, switches, fields, picker wheels, lists, navigation bars and dialogs. Use them when the interface should look like an iPhone app; otherwise use the Material elements. Many of them are drawn on the site only as a picture with no behavior — see the differences .

    Callbacks receive the value by name. The argument name must match the one the element passes: onChanged:(value){…} on a switch, onTap:(index){…} on a tab bar. A callback (v){…} receives nothing.

    Element Type What it is
    `CupertinoButton` single-child iOS button: plain, filled, tinted
    `CupertinoSwitch` leaf Switch
    `CupertinoSlider` leaf Slider
    `CupertinoTextField` leaf Text field
    `CupertinoActivityIndicator` leaf Spinning activity indicator
    `CupertinoPicker` multi-child Picker wheel of its own children
    `CupertinoDatePicker` leaf Date and time wheel
    `CupertinoTimerPicker` leaf Duration wheel
    `CupertinoListSection` multi-child Group of list rows
    `CupertinoListTile` multi-child List row
    `CupertinoNavigationBar` multi-child Top navigation bar
    `CupertinoTabBar` multi-child Bottom tab bar
    `CupertinoPageScaffold` multi-child Page scaffold: bar + content
    `CupertinoAlertDialog` multi-child Alert dialog
    `CupertinoDialogAction` single-child Dialog button
    `CupertinoActionSheet` multi-child List of actions at the bottom
    `CupertinoActionSheetAction` single-child Action sheet button

    CupertinoButton

    An iOS button. variant picks the look: without it — plain (text color is foregroundColor , by default the theme's primary color; color fills the background with exactly that color), filled — filled ( color or the theme's primary color, white text), tinted — a translucent backing in color .

    Type: single-child

    @count:0
    
    CupertinoButton variant:filled color:#007aff onPressed:(){count = count + 1}
      Text "Done"
    Parameter Type Default Description
    onPressed callback — Tap. Without it the button is disabled
    variant string — filled or tinted ; without it — a plain button
    color color — Background (transparent on a plain button if not set)
    foregroundColor color from the theme Color of text and icons
    disabledColor color system gray Background of a disabled plain button
    #padding structure from the theme Inner padding
    #borderRadius structure circular 8 Corner radius
    minimumSize double 44 Minimum side of the button (a minimumSize × minimumSize square)
    pressedOpacity double 0.4 Opacity while pressed
    @count:0
    
    Row spacing:12
      CupertinoButton onPressed:(){count = count + 1}
        Text "Plain"
      CupertinoButton variant:tinted color:#34c759 onPressed:(){count = count + 1}
        Text "Tinted"
      CupertinoButton color:#ffffff foregroundColor:#007aff onPressed:(){count = count + 1}
        #borderRadius circular 20
        Text "Chip"

    CupertinoSwitch

    An iOS switch. It holds no value itself: it shows value and reports the new one through onChanged .

    Type: leaf

    @wifi:true
    
    CupertinoSwitch value:$wifi onChanged:(value){wifi = value}
    Parameter Type Default Description
    value bool false Whether the switch is on
    onChanged callback (value) — Tap; value is the new value. Without it the switch is disabled
    activeTrackColor color system green Track color when on
    thumbColor color white Thumb color

    Switch and indicator

    @busy:true
    
    Row spacing:16
      CupertinoSwitch value:$busy onChanged:(value){busy = value}
      CupertinoActivityIndicator radius:14
      Text {busy ? "Loading is on" : "Loading is off"}

    CupertinoSlider

    An iOS slider.

    Type: leaf

    @volume:0.5
    
    CupertinoSlider value:$volume onChanged:(value){volume = value}
    Parameter Type Default Description
    value double 0 Current value, between min and max
    onChanged callback (value) — Slider moved; value is the new value. Without it the slider is disabled
    min double 0 Lower bound
    max double 1 Upper bound
    divisions int — Number of divisions: the slider snaps only to them
    activeColor color from the theme Color of the filled part
    thumbColor color white Thumb color
    @level:50
    
    CupertinoSlider value:$level min:0 max:100 divisions:10 activeColor:#007aff onChanged:(value){level = value}

    CupertinoTextField

    An iOS text field. value:$var binds the field to a variable both ways : typing writes to the variable, and changing the variable (for example, with a "clear" button) changes the text in the field.

    Type: leaf

    @query:""
    
    CupertinoTextField value:$query placeholder:"Search"
    Parameter Type Default Description
    value string (reactive) — Variable bound to the field's text
    placeholder string — Hint in an empty field
    onChanged callback (value) — Every change of the text
    onSubmitted callback (value) — Input confirmed with a key
    #padding structure all 6 Inner padding
    #style structure — Text style (TextStyle)
    obscureText bool false Hide the input (password)
    readOnly bool false Read only
    autofocus bool false Focus on appearance
    maxLines int 1 Number of lines
    maxLength int — Length limit
    @name:""
    @sent:""
    
    Column spacing:8
      CupertinoTextField value:$name placeholder:"Name" maxLength:50 onSubmitted:(value){sent = value}
        #padding all 12
        #style fontSize:16 color:#1c1c1e
      CupertinoButton onPressed:(){name = ""}
        Text "Clear"

    CupertinoActivityIndicator

    The iOS loading indicator — a spinning wheel of petals.

    Type: leaf

    CupertinoActivityIndicator
    Parameter Type Default Description
    animating bool true Whether it spins; false — still
    radius double 10 Radius
    color color system gray Petal color
    CupertinoActivityIndicator radius:20 color:#007aff

    CupertinoPicker

    An iOS picker wheel made of its own children: all children without an id are the items. It needs a bounded height ( SizedBox height: ). Without itemExtent the element is not drawn.

    Type: multi-child

    @fruit:0
    
    SizedBox height:180
      CupertinoPicker itemExtent:32 onSelectedItemChanged:(index){fruit = index}
        Text "Apple"
        Text "Pear"
        Text "Plum"
    Parameter Type Default Description
    itemExtent double — Height of one item. Required
    onSelectedItemChanged callback (index) — An item was selected; index is its zero-based number
    looping bool false The wheel is closed: the first item follows the last
    diameterRatio double 1.07 Ratio of the cylinder's diameter to the window height
    squeeze double 1.45 Density of items on the wheel
    backgroundColor color — Wheel background

    CupertinoDatePicker

    An iOS wheel for a date and/or time. It needs a bounded height.

    Type: leaf

    @picked:0
    
    SizedBox height:216
      CupertinoDatePicker mode:date onDateTimeChanged:(value){picked = value}
    Parameter Type Default Description
    mode string date date , time or dateAndTime
    initialDateTime int now Initial date — milliseconds since 1970-01-01 (UTC)
    onDateTimeChanged callback (value) — The date changed; value is milliseconds since 1970-01-01
    use24hFormat bool false 24-hour time format
    minimumYear int 1 Earliest year
    maximumYear int — Latest year
    backgroundColor color — Wheel background
    @picked:0
    
    SizedBox height:216
      CupertinoDatePicker mode:dateAndTime use24hFormat:true initialDateTime:1767225600000 minimumYear:2020 maximumYear:2030 backgroundColor:#ffffff onDateTimeChanged:(value){picked = value}

    CupertinoTimerPicker

    An iOS duration wheel: hours, minutes, seconds.

    Type: leaf

    @seconds:0
    
    CupertinoTimerPicker mode:hm initialTimerDuration:300s onTimerDurationChanged:(duration){seconds = duration}
    Parameter Type Default Description
    mode string hms Wheels: hm (hours, minutes), ms (minutes, seconds), hms
    initialTimerDuration duration 0s Initial duration ( 300s )
    onTimerDurationChanged callback (duration) — The duration changed; duration is a number of seconds
    backgroundColor color — Wheel background

    CupertinoListSection

    An iOS group of list rows: a header, rows and a footer. The rows are all children without an id (usually CupertinoListTile ).

    Type: multi-child

    CupertinoListSection
      Text id:header "General"
      CupertinoListTile
        Text id:title "Notifications"
      CupertinoListTile
        Text id:title "Privacy"
    Parameter Type Default Description
    backgroundColor color system grouped background Section background
    separatorColor color from the theme Color of the lines between rows
    #margin structure 0 Outer margins of the section

    Slots: id:header — the header above the rows, id:footer — the caption below them.

    CupertinoListTile

    An iOS list row. Its parts come from the children's id: . Without id:title the row is not drawn.

    Type: multi-child

    @opened:0
    
    CupertinoListTile onTap:(){opened = opened + 1}
      Icon id:leading settings
      Text id:title "Settings"
      Text id:subtitle "Sound, display, notifications"
      Icon id:trailing chevron_right
    Slot id What it is
    title Main text (required)
    subtitle Text under the main one
    leading Icon on the left
    trailing Icon on the right
    additionalInfo Extra text before trailing
    Parameter Type Default Description
    onTap callback — Tap on the row
    #padding structure from the theme Inner padding
    backgroundColor color — Row background
    backgroundColorActivated color from the theme Background while pressed

    CupertinoNavigationBar

    The iOS top navigation bar: a title in the middle, items at the edges.

    Type: multi-child

    CupertinoNavigationBar backgroundColor:#f8f8f8
      Text id:middle "Notes"

    Slots: id:middle — the title, id:leading — on the left, id:trailing — on the right.

    Parameter Type Default Description
    backgroundColor color from the theme Bar background
    automaticallyImplyLeading bool true Show a "back" button by itself when there is somewhere to go back to
    automaticallyImplyMiddle bool true Show the route title by itself when middle is not set
    previousPageTitle string — Label next to the "back" button
    @edits:0
    
    CupertinoNavigationBar previousPageTitle:"Back"
      Text id:middle "Note"
      CupertinoButton id:trailing onPressed:(){edits = edits + 1}
        Text "Edit"

    CupertinoTabBar

    The iOS bottom tab bar. The tabs are children with id:item : the child itself is the icon, its label is the caption. Without a single id:item the bar is not drawn.

    Type: multi-child

    @tab:0
    
    CupertinoTabBar currentIndex:$tab onTap:(index){tab = index}
      Icon id:item label:"Home" home
      Icon id:item label:"Search" search
      Icon id:item label:"Profile" person
    Parameter Type Default Description
    currentIndex int 0 Index of the active tab
    onTap callback (index) — Tap on a tab; index is its number
    activeColor color from the theme Color of the active tab
    inactiveColor color system gray Color of the others
    backgroundColor color from the theme Bar background

    The bar only shows the tabs: switching the content by tab is up to the markup (for example, Switcher ).

    CupertinoPageScaffold

    The iOS page scaffold: a navigation bar on top and the content.

    Type: multi-child

    CupertinoPageScaffold
      CupertinoNavigationBar id:navigationBar
        Text id:middle "Settings"
      Center id:child
        Text "Content"

    Slots: id:navigationBar — the bar (must be a CupertinoNavigationBar , otherwise it is not shown), id:child — the content; without it the first child without an id is taken.

    Parameter Type Default Description
    backgroundColor color from the theme Page background
    resizeToAvoidBottomInset bool true Shrink the content when the keyboard is open

    Settings screen

    @sound:true
    
    CupertinoPageScaffold backgroundColor:#f2f2f7
      CupertinoNavigationBar id:navigationBar
        Text id:middle "Settings"
      Column id:child
        CupertinoListSection separatorColor:#c6c6c8
          Text id:header "General"
          Text id:footer "Changes take effect immediately"
          CupertinoListTile
            Text id:title "Sound"
            CupertinoSwitch id:trailing value:$sound onChanged:(value){sound = value}
          CupertinoListTile
            Text id:title "Language"
            Text id:additionalInfo "English"
            Icon id:trailing chevron_right

    CupertinoAlertDialog

    An iOS alert dialog: a title, text and buttons. It is drawn where it stands in the tree; to show it on a tap, put it inside a declared `Dialog id:` .

    Type: multi-child

    @answer:""
    
    CupertinoAlertDialog
      Text id:title "Delete?"
      Text id:content "This cannot be undone."
      CupertinoDialogAction id:action onPressed:(){answer = "cancel"}
        Text "Cancel"
      CupertinoDialogAction id:action isDestructiveAction:true onPressed:(){answer = "delete"}
        Text "Delete"

    Slots: id:title , id:content , id:action (there can be several buttons; use CupertinoDialogAction ). It has no parameters other than the slots.

    CupertinoDialogAction

    A button inside a CupertinoAlertDialog .

    Type: single-child

    @ok:false
    
    CupertinoDialogAction isDefaultAction:true onPressed:(){ok = true}
      Text "OK"
    Parameter Type Default Description
    onPressed callback — Tap. Without it the button is disabled (gray)
    isDefaultAction bool false The default action — bold text
    isDestructiveAction bool false A destructive action — red text

    CupertinoActionSheet

    An iOS action sheet: a title, an explanation, buttons and a separate cancel button.

    Type: multi-child

    @shared:""
    
    CupertinoActionSheet
      Text id:title "Share"
      Text id:message "Choose how"
      CupertinoActionSheetAction id:action onPressed:(){shared = "link"}
        Text "Copy link"
      CupertinoActionSheetAction id:cancel onPressed:(){shared = ""}
        Text "Cancel"

    Slots: id:title , id:message , id:action (several), id:cancel (one cancel button, separately at the bottom). It has no parameters other than the slots.

    CupertinoActionSheetAction

    A button inside a CupertinoActionSheet .

    Type: single-child

    @opened:false
    
    CupertinoActionSheetAction isDefaultAction:true onPressed:(){opened = true}
      Text "Open"
    Parameter Type Default Description
    onPressed callback — Tap
    isDefaultAction bool false The default action — bold text
    isDestructiveAction bool false A destructive action — red text

    Differences between the app and the site

    These work on the site the same way as in the app: CupertinoSwitch (a real switch bound to the variable) and CupertinoPageScaffold (bar and content, backgroundColor ). The rest look similar but lack part of the behavior:

    • Taps are not delivered to CupertinoButton , CupertinoDialogAction , CupertinoActionSheetAction and CupertinoListTile : onPressed and onTap stay silent on the site. For an action on the site use Material buttons .
    • CupertinoButton : filled — a color fill with white text, the other variants — text color only; tinted gets no backing. foregroundColor , #padding , #borderRadius , minimumSize , pressedOpacity , disabledColor are not read.
    • CupertinoSwitch : the on color is system green; activeTrackColor and thumbColor are not read on the site.
    • CupertinoSlider is a still picture: a track and a thumb at value , where the value is treated as a fraction from 0 to 1 ( min / max are ignored). It cannot be moved, onChanged is not called.
    • CupertinoTextField is a frame with the placeholder text; you cannot type in it , value is not bound. For input on the site use TextField .
    • CupertinoActivityIndicator always spins, animating:false is not read.
    • CupertinoPicker is a still column of items five itemExtent tall, the middle one highlighted; it does not scroll, onSelectedItemChanged is not called.
    • CupertinoDatePicker is always three still wheels "month (in English) / day / year" around initialDateTime ; mode , use24hFormat , the year bounds and onDateTimeChanged are not read.
    • CupertinoTimerPicker is not drawn on the site (unsupported widget).
    • CupertinoTabBar is not supported (unsupported widget): only the children's icons are output in a row, with no captions and no bar.
    • CupertinoListSection : the header, rows and footer are drawn; separatorColor , backgroundColor , #margin are not read. CupertinoListTile : additionalInfo and backgroundColor are not read.
    • CupertinoNavigationBar sticks to the top of the page; backgroundColor is read, there is no "back" button and no previousPageTitle .
    • CupertinoAlertDialog is a 270-wide card in place of the element, two buttons in a row. CupertinoActionSheet is a 320-wide card with the title and the id:action buttons; id:message and id:cancel are not output on the site.

    See also