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

    Screen scaffold

    The Material screen scaffold: Scaffold lays a screen out into a top bar, a body, bottom navigation, a floating button and side menus; AppBar is the top bar, BottomAppBar is the bottom bar, Drawer is a sliding side menu. The parts of the scaffold are passed as slots — children with an id: .

    Use Scaffold as the root of an app screen. A site page without bars and menus does not need it — a Column or a scrolling element is enough.

    Scaffold

    The root of a screen. Each child becomes a part of the scaffold according to its id: . The body is the child with id:body ; if there is none, the body is the first child without an id: (so a Scaffold with a single child, or with a wrapper such as JsonData around the page, works without any marks).

    Type: multi-child (slots by id: )

    Scaffold
      AppBar id:appBar
        Text id:title "Home"
      Center id:body
        Text "Screen content"

    Slots

    id: What it is
    appBar The top bar, usually an AppBar
    body The body of the screen
    floatingActionButton The floating button ( FloatingActionButton )
    drawer The side menu on the left, usually a Drawer . With it, the AppBar shows a menu button by itself
    endDrawer The side menu on the right
    bottomNavigationBar The bottom bar: NavigationBar , BottomNavigationBar or BottomAppBar
    bottomSheet A persistent bottom sheet above the bottom bar

    Parameters

    Parameter Type Default Description
    backgroundColor color from the theme Screen background
    floatingActionButtonLocation string endFloat Where the floating button goes: endFloat , centerFloat , startFloat , endDocked , centerDocked , startDocked , miniStartFloat , miniEndFloat , miniCenterFloat . …Docked sets the button into the bottom bar
    appBarHeight double 56 Height of the appBar slot when it holds something other than an AppBar (your own element — Container , Row …). The height of an AppBar itself is set by its toolbarHeight
    resizeToAvoidBottomInset bool — Shrink the body when the on-screen keyboard is open (yes by default)
    primary bool true The screen takes the top of the window: the bar gets padding for the status bar
    extendBody bool false The body extends under the bottom bar (visible through its transparent edges and notch)
    extendBodyBehindAppBar bool false The body extends under the top bar — for a transparent bar over a picture

    Example: a screen with a menu and a floating button

    @count:0
    Scaffold backgroundColor:#f8fafc
      AppBar id:appBar
        Text id:title "Notes"
      Drawer id:drawer
        Column
          ListTile
            Icon id:leading home
            Text id:title "Home"
          ListTile
            Icon id:leading settings
            Text id:title "Settings"
      Center id:body
        Text $"Notes: ${count}"
      FloatingActionButton id:floatingActionButton tooltip:"Add" onPressed:(){count = count + 1}
        Icon add

    AppBar

    The top bar of a screen: a button on the left, a title, action buttons on the right. It goes into the id:appBar slot of a Scaffold .

    Type: multi-child (slots by id: )

    AppBar backgroundColor:#4f46e5 foregroundColor:#ffffff
      Text id:title "Profile"

    Slots

    id: What it is
    title The title
    leading The element on the left. Without it the bar puts a "back" button or a menu button there by itself (see automaticallyImplyLeading )
    action An action button on the right. There can be several such children — they go in order

    Parameters

    Parameter Type Default Description
    backgroundColor color from the theme Bar background
    foregroundColor color from the theme Colour of the title and icons
    centerTitle bool by platform Centre the title (by default yes on iOS, no on Android)
    automaticallyImplyLeading bool true Without leading , put a "back" or menu ( drawer ) button there by itself
    toolbarHeight double 56 Bar height
    leadingWidth double — Width of the space for leading
    titleSpacing double — Horizontal spacing around the title
    elevation double — Elevation (shadow)
    scrolledUnderElevation double — Elevation when content has scrolled under the bar
    shadowColor color — Shadow colour
    surfaceTintColor color — Surface tint when elevated (Material 3)
    shape #shape — Bar shape, for example a rounded bottom
    toolbarOpacity double 1.0 Opacity of the bar content (0…1)
    bottomOpacity double 1.0 Opacity of the bottom part of the bar (0…1)
    clipBehavior string — Clipping to the shape: none , hardEdge , antiAlias , antiAliasWithSaveLayer
    AppBar centerTitle:true
      IconButton id:leading tooltip:"Back" onPressed:(){navigator.show("/home")}
        Icon arrow_back
      Text id:title "Details"
      IconButton id:action tooltip:"Search" onPressed:(){}
        Icon search
      IconButton id:action tooltip:"More" onPressed:(){}
        Icon more_vert

    BottomAppBar

    A bottom bar for buttons; it goes into the id:bottomNavigationBar slot. It can have a notch for the floating button if the Scaffold places that button …Docked .

    Type: single-child

    BottomAppBar
      Row alignment:spaceAround
        IconButton tooltip:"Home" onPressed:(){}
          Icon home
        IconButton tooltip:"Profile" onPressed:(){}
          Icon person
    Parameter Type Default Description
    color color from the theme Bar background
    elevation double — Elevation (shadow)
    shadowColor color — Shadow colour
    surfaceTintColor color — Surface tint when elevated
    notchShape string — Notch for the floating button. The only value is circular (a round notch)
    notchMargin double 4.0 Gap between the button and the edge of the notch
    padding #padding — Inner padding of the bar
    height double — Bar height
    clipBehavior string none Clipping to the shape
    Scaffold floatingActionButtonLocation:centerDocked
      Center id:body
        Text "Screen"
      BottomAppBar id:bottomNavigationBar notchShape:circular notchMargin:6
        Row alignment:spaceAround
          IconButton tooltip:"Home" onPressed:(){}
            Icon home
          SizedBox width:48
          IconButton tooltip:"Profile" onPressed:(){}
            Icon person
      FloatingActionButton id:floatingActionButton tooltip:"Add" onPressed:(){}
        Icon add

    Drawer

    A sliding side menu. It goes into the id:drawer (left) or id:endDrawer (right) slot of a Scaffold ; it opens with the menu button on the AppBar or with a swipe from the screen edge.

    Type: single-child

    Drawer
      Column
        ListTile
          Text id:title "Home"
        ListTile
          Text id:title "Settings"
    Parameter Type Default Description
    backgroundColor color from the theme Menu background
    width double from the theme Menu width
    elevation double — Elevation (shadow)
    shadowColor color — Shadow colour
    surfaceTintColor color — Surface tint when elevated
    shape #shape — Shape, for example rounded outer corners
    clipBehavior string — Clipping to the shape

    Differences between the app and the site

    On the site Scaffold is drawn as a page column: header ( appBar ), body ( body ), bottom bar ( bottomNavigationBar ) and the floating button.

    • The drawer , endDrawer and bottomSheet slots are not output on the site: there is no side menu and no sheet. For a site, make the menu a visible block shown depending on state ( if: or Switcher ).
    • On the site the floating button is always pinned to the bottom right corner of the window (20 px from the right, 76 px from the bottom); floatingActionButtonLocation is ignored.
    • Of the Scaffold parameters, the site reads only backgroundColor .
    • AppBar on the site is a 56 px high <header> row: leading , the title (titleLarge style), the action buttons; backgroundColor and foregroundColor are read. The title is always on the left ( centerTitle is ignored), and so are toolbarHeight , elevation , shape and the rest. The "back"/menu button does not appear by itself.
    • BottomAppBar on the site is a row at least 56 px high with color and a light shadow on top; height , padding , elevation and the notch ( notchShape ) are ignored.
    • A Drawer placed directly in the markup (not in a slot) is drawn on the site as a panel with a background and a shadow, the full height of its parent; width is ignored — the panel takes the width of its parent.

    See also

    • Navigation and tabs — bottom navigation and tabs for the bottomNavigationBar slot
    • List tiles — menu items inside a Drawer
    • Button — buttons for leading , action and the floating button
    • Switcher — switching the body content by the selected item