LiquidGlassScope.stack constructor

  1. @Deprecated('Use GlassPage instead. GlassPage automatically handles Scaffold transparency ' 'and adaptive quality degradation. This factory will be removed in 1.0.0.')
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: GlassBackgroundSource(child: background),
      ),
      Positioned.fill(child: content),
    ],
  ),
)

Example:

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

Implementation

@Deprecated(
  'Use GlassPage instead. GlassPage automatically handles Scaffold transparency '
  'and adaptive quality degradation. This factory will be removed in 1.0.0.',
)
factory LiquidGlassScope.stack({
  Key? key,
  required Widget background,
  required Widget content,
}) {
  return LiquidGlassScope(
    key: key,
    child: Stack(
      children: [
        Positioned.fill(
          child: GlassBackgroundSource(child: background),
        ),
        content, // Don't wrap in Positioned - let it naturally fill
      ],
    ),
  );
}