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

    Material surfaces

    Material surfaces and markers: the card Card , the base surface Material , the round avatar CircleAvatar , the counter badge Badge , the corner ribbon Banner and the popup hint Tooltip . All of them wrap one child.

    For a plain background, border or gradient without Material rules, DecoratedBox or Container is enough.

    Card

    A card: a raised surface with rounded corners and a shadow for a group of content. Without its own parameters the colour and shape come from the theme.

    Type: single-child

    Card
      Padding
        #padding all 16
        Text "A simple card"
    Parameter Type Default Description
    color color from the theme Surface colour
    elevation double from the theme Elevation — the strength of the shadow
    shadowColor color — Shadow colour
    surfaceTintColor color — The surface tint Material 3 mixes in as elevation grows
    shape #shape from the theme Shape: rounded , stadium , circle , beveled , … with their own #borderRadius and #side
    margin #margin from the theme Outer space around the card (like `#padding` )
    clipBehavior string none Clipping the content to the shape: none , hardEdge , antiAlias , antiAliasWithSaveLayer
    Column spacing:12
      Card elevation:4 color:#ffffff
        #margin all 8
        Padding
          #padding all 16
          Row spacing:12
            CircleAvatar radius:20 backgroundColor:#4f46e5
              Text "AS"
                #style color:#ffffff fontWeight:bold
            Column crossAlignment:start
              Text "Anna Smith"
                #style fontWeight:bold
              Text "Designer"
                #style color:#64748b
      Card elevation:0 color:#eef2ff
        #margin all 8
        Padding
          #padding all 16
          Text "A flat card without a shadow"

    Material

    The base Material surface: colour, shadow, shape and a layer for press effects . The ripple of an InkWell is drawn on the nearest Material above it in the tree — if there is an opaque background between them, the ripple is hidden under it. In that case wrap the tappable area in Material type:transparency .

    Type: single-child

    Material elevation:2 color:#ffffff
      #borderRadius circular 12
      Padding
        #padding all 16
        Text "A Material surface"
    Parameter Type Default Description
    type string canvas Kind of surface: canvas , card , circle , button , transparency (a transparent layer just for the ripple)
    elevation double 0 Elevation — the strength of the shadow
    color color from the theme Surface colour
    shadowColor color — Shadow colour
    surfaceTintColor color — Surface tint when raised (Material 3)
    borderRadius #borderRadius — Corner rounding
    shape #shape — Surface shape (as for Card )
    clipBehavior string none Clipping the content to the shape

    Set either #borderRadius or #shape : Flutter does not accept both at once.

    Material type:transparency
      InkWell onTap:(){}
        Padding
          #padding all 16
          Text "Tap — there will be a ripple"

    CircleAvatar

    A circle with initials, an icon or a picture — a user avatar. The size is set by the radius; without it, 20.

    Type: single-child

    CircleAvatar radius:24 backgroundColor:#4f46e5
      Text "AB"
        #style color:#ffffff fontWeight:bold
    Parameter Type Default Description
    radius double 20 The circle's radius. Does not combine with minRadius / maxRadius
    minRadius double — Smallest radius (when the parent sets the size)
    maxRadius double — Largest radius
    backgroundColor color from the theme Circle colour
    foregroundColor color from the theme Colour of text and icons inside
    backgroundImage #backgroundImage — Background picture: #backgroundImage network url:"…" or #backgroundImage asset path:"…"
    foregroundImage #foregroundImage — A picture over the background and the child (in the same form). While it loads, or if it fails to load, the background with initials is visible
    CircleAvatar radius:28 backgroundColor:#e2e8f0
      #backgroundImage network url:"https://example.com/avatar.png"

    Badge

    A counter marker in the corner of the child: the number of unread items over an icon. Without count — a small dot.

    Type: single-child

    Badge count:5
      Icon notifications
    Parameter Type Default Description
    count int — The number on the marker. Without it the marker is a dot with no text
    isLabelVisible bool true Whether to show the marker ( false — only the child is visible)
    backgroundColor color from the theme Marker colour
    textColor color from the theme Number colour
    textStyle #textStyle — Number style
    padding #padding — Padding inside a marker with a number
    alignment alignment — The point of the child the marker is attached to ( topEnd , topRight , …)
    offset #offset — Marker offset: #offset x:… y:…
    largeSize double — Height of a marker with a number
    smallSize double — Diameter of a dot marker
    @unread:3
    Badge count:$unread isLabelVisible:{unread > 0} backgroundColor:#dc2626
      Icon mail

    A diagonal ribbon in the corner of the child — “BETA”, “NEW”, “-20 %”. The ribbon is clipped to the child's bounds.

    Type: single-child

    Banner message:"BETA" location:topEnd color:#dc2626
      SizedBox width:200 height:120
        ColoredBox color:#f5f5f4
    Parameter Type Default Description
    message string "" Text on the ribbon
    location string topEnd Corner: topStart , topEnd , bottomStart , bottomEnd
    color color red Ribbon colour
    textStyle #textStyle white, bold, ~10 px Ribbon text style
    textDirection string — Text direction ( ltr / rtl ) — it decides where the “start” is in topStart / bottomStart
    Row spacing:16
      Banner message:"NEW" location:topEnd color:#059669
        SizedBox width:140 height:90
          ColoredBox color:#ecfdf5
      Banner message:"-20 %" location:topStart color:#dc2626
        SizedBox width:140 height:90
          ColoredBox color:#fef2f2

    Tooltip

    A hint with text that appears when the pointer hovers over the child or on a long press. The text goes as a positional argument or in message: . With empty text there is no hint — only the child is drawn.

    Type: single-child

    Tooltip "More details"
      Icon info color:#475569
    Parameter Type Default Description
    (positional) string — Hint text, same as message
    message string — Hint text
    triggerMode string longPress How to trigger it on a touch screen: longPress , tap , manual
    waitDuration int, ms — How many milliseconds the pointer has to stay before the hint appears; 0 — at once
    showDuration int, ms — How many milliseconds the hint stays after the pointer leaves
    preferBelow bool — Show below the child ( false — above it, if there is room)
    verticalOffset double — Distance from the child to the hint
    height double — Bubble height
    padding #padding — Padding inside the bubble
    margin #margin — Bubble margin from the screen edges
    textStyle #textStyle — Text style
    decoration #decoration — Bubble background (as for DecoratedBox )
    Tooltip message:"Delete" waitDuration:0 preferBelow:false
      #decoration color:#1e293b
        #borderRadius circular 6
      #textStyle color:#ffffff fontSize:12
      Icon delete color:#dc2626

    Differences between the app and the site

    • Card on the site is a block with a background, a shadow by elevation (1 by default) and margin . The rounding is always 12 px: shape and clipBehavior are not read. shadowColor , surfaceTintColor are not read.
    • Material on the site is a block with color , a shadow by elevation and #borderRadius . type (including circle ), shape , clipBehavior , shadowColor , surfaceTintColor are not read: Material type:circle comes out as a rectangle on the site.
    • CircleAvatar on the site is a circle of diameter 2 × radius (40 px by default) with backgroundColor (without it — grey #bdbdbd ), foregroundColor and #backgroundImage . minRadius , maxRadius and foregroundImage are not read.
    • Badge is not supported on the site (an unsupported widget warning): only the child is drawn, there is no marker.
    • Banner on the site always puts the ribbon at the top edge : bottomStart / bottomEnd come out as topStart / topEnd . The text style is fixed (white, 10 px, bold), textStyle and textDirection are not read; the default colour is #dc2626 .
    • Tooltip on the site draws only the child : there is no hint. If the hint carries meaning (a caption for an icon button), duplicate it as visible text; the name for screen readers comes from tooltip: on an IconButton or from Semantics label: .

    See also

    • DecoratedBox , Container — background, border, shadow without Material rules
    • InkWell — the press ripple, which needs a Material above it
    • Icon — a child for Badge and Tooltip
    • List rows — CircleAvatar in the leading slot