LiquidGlassScope.stack constructor

LiquidGlassScope.stack({
  1. Key? key,
  2. required Widget background,
  3. required Widget content,
})

Convenience constructor for the common pattern of a background behind content.

This eliminates the boilerplate of manually creating a Stack with Positioned.fill widgets. It's equivalent to:

LiquidGlassScope(
  child: Stack(
    children: [
      Positioned.fill(
        child: LiquidGlassBackground(child: background),
      ),
      Positioned.fill(child: content),
    ],
  ),
)

Example:

LiquidGlassScope.stack(
  background: Image.asset('wallpaper.jpg', fit: BoxFit.cover),
  content: Scaffold(
    body: MyContent(),
    bottomNavigationBar: GlassBottomBar(...),
  ),
)

Implementation

factory LiquidGlassScope.stack({
  Key? key,
  required Widget background,
  required Widget content,
}) {
  return LiquidGlassScope(
    key: key,
    child: Stack(
      children: [
        Positioned.fill(
          child: LiquidGlassBackground(child: background),
        ),
        content, // Don't wrap in Positioned - let it naturally fill
      ],
    ),
  );
}