GlassContainer.card constructor

const GlassContainer.card({
  1. Key? key,
  2. Widget? child,
  3. EdgeInsetsGeometry? padding = const EdgeInsets.all(16),
  4. EdgeInsetsGeometry? margin,
  5. LiquidShape? shape,
  6. LiquidGlassSettings? settings,
  7. bool useOwnLayer = false,
  8. GlassQuality? quality,
  9. Clip clipBehavior = Clip.none,
  10. double? width,
  11. double? height,
  12. Color? color,
  13. GlassSurfaceStyle surfaceStyle = GlassSurfaceStyle.glass,
})

Creates a card-like container with opinionated defaults.

Defaults match the (deprecated) GlassCard: padding of 16 on all sides and, for GlassSurfaceStyle.glass, a 12px LiquidRoundedSuperellipse.

surfaceStyle chooses how the card is painted:

  • GlassSurfaceStyle.glass (default in 1.x): the normal glass surface.
  • GlassSurfaceStyle.solid: a flat opaque fill (white in light mode, #1C1C1E in dark mode) with no blur, rim, refraction or shadow, matching native iOS inset-grouped list cards. When shape is null the solid card uses a 26px LiquidRoundedSuperellipse. settings, useOwnLayer and quality are ignored for solid cards. The dark fill is always #1C1C1E; the lighter "elevated" grey iOS uses for cards inside sheets is not implemented.

iOS draws list cards flat; prefer GlassSurfaceStyle.solid for cards inside lists.

Implementation

const GlassContainer.card({
  super.key,
  this.child,
  this.padding = const EdgeInsets.all(16),
  this.margin,
  LiquidShape? shape,
  this.settings,
  this.useOwnLayer = false,
  this.quality,
  this.clipBehavior = Clip.none,
  this.width,
  this.height,
  this.color,
  GlassSurfaceStyle surfaceStyle = GlassSurfaceStyle.glass,
})  : shape = shape ??
          (surfaceStyle == GlassSurfaceStyle.solid
              ? _solidCardShape
              : _glassCardShape),
      alignment = null,
      allowElevation = false,
      glowIntensity = 0.0,
      platformViewBackdrop = false,
      _surfaceStyle = surfaceStyle;