### Navigate to Example Directory Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/example/README.md Navigate to the example directory before proceeding with dependency installation. ```bash cd example ``` -------------------------------- ### Run Widget Showcase App Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Navigate to the example directory, install dependencies, and run the app to explore the full library of 36 glass widgets, experiment with live settings, and copy patterns. ```bash cd example && flutter pub get && flutter run ``` -------------------------------- ### Run Wanderlust Showcase App Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Navigate to the Wanderlust example directory, install dependencies, and run the app to see a premium showcase of liquid glass widgets in a real-world production context. ```bash cd example/showcase && flutter pub get && flutter run ``` -------------------------------- ### Library Setup - App Wrapping Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Wraps your app in the Liquid Glass infrastructure scopes, installing `GlassBackdropScope` for shared GPU backdrop capture and optionally enabling adaptive quality. ```APIDOC ## LiquidGlassWidgets.wrap() ### Description Wraps your app in the Liquid Glass infrastructure scopes, installing `GlassBackdropScope` for shared GPU backdrop capture and optionally enabling adaptive quality. This roughly halves blit cost when multiple glass widgets are visible simultaneously. ### Method `LiquidGlassWidgets.wrap(Widget child, {bool adaptiveQuality = false, bool respectSystemAccessibility = true, GlassAdaptiveScopeConfig? adaptiveConfig})` ### Parameters #### Required Parameters - **child** (Widget) - The root widget of your application. #### Optional Parameters - **adaptiveQuality** (bool) - Enables adaptive quality for broader device support. Defaults to `false`. - **respectSystemAccessibility** (bool) - Respects OS accessibility settings like Reduce Motion and Reduce Transparency. Defaults to `true`. - **adaptiveConfig** (GlassAdaptiveScopeConfig) - Configuration for adaptive quality settings. - **initialQuality** (GlassQuality) - The initial glass quality setting. - **allowStepUp** (bool) - Whether to allow stepping up the quality. - **onQualityChanged** (Function(GlassQuality from, GlassQuality to)) - Callback when quality changes. ### Request Example ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); await LiquidGlassWidgets.initialize(); // Zero-config setup (most apps) runApp(LiquidGlassWidgets.wrap(const MyApp())); // With adaptive quality for Android/broad device support runApp(LiquidGlassWidgets.wrap( const MyApp(), adaptiveQuality: true, )); // Full configuration with persistent quality settings final prefs = await SharedPreferences.getInstance(); final savedQuality = prefs.getString('glass_quality'); final initialQuality = savedQuality != null ? GlassQuality.values.byName(savedQuality) : null; runApp(LiquidGlassWidgets.wrap( const MyApp(), respectSystemAccessibility: true, // Default: respects OS settings adaptiveQuality: true, adaptiveConfig: GlassAdaptiveScopeConfig( initialQuality: initialQuality ?? GlassQuality.standard, allowStepUp: true, onQualityChanged: (from, to) => prefs.setString('glass_quality', to.name), ), )); } ``` ``` -------------------------------- ### Run Apple Music Demo App Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Navigate to the example directory, install dependencies, and run the Apple Music demo to see a recreation of the iOS 26 navigation model with morphing transitions. ```bash cd example && flutter pub get && flutter run -t lib/apple_music/apple_music_demo.dart ``` -------------------------------- ### Run Apple News Demo App Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Navigate to the example directory, install dependencies, and run the Apple News demo to see a recreation of the iOS 26 app with its morphing search pill and hero cards. ```bash cd example && flutter pub get && flutter run -t lib/apple_news/apple_news_demo.dart ``` -------------------------------- ### Configure GlassSwitch Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Example of a GlassSwitch, demonstrating its basic usage with state management for toggle functionality. ```dart GlassSwitch( value: isDarkMode, onChanged: (value) => setState(() => isDarkMode = value), activeColor: Colors.green, inactiveColor: Colors.grey.withOpacity(0.3), thumbColor: Colors.white, width: 58, height: 26, quality: GlassQuality.standard, ) ``` -------------------------------- ### Run Showcase App Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/example/showcase/README.md Navigate to the showcase directory, install dependencies, and run the app using Flutter. ```bash cd showcase flutter pub get flutter run ``` -------------------------------- ### Library Setup - Initialization Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Initializes platform-level resources including shader prewarming and Impeller pipeline compilation. Must be called once in `main()` before `runApp`. ```APIDOC ## LiquidGlassWidgets.initialize() ### Description Initializes platform-level resources including shader prewarming, Impeller pipeline compilation, and optional debug performance monitoring. Must be called once in `main()` before `runApp`. This eliminates the "white flash" on first render by pre-caching all shaders. ### Method `LiquidGlassWidgets.initialize()` ### Parameters #### Optional Parameters - **enablePerformanceMonitor** (bool) - Optional - Set to `false` to disable the debug performance monitor. ### Request Example ```dart import 'package:flutter/material.dart'; import 'package:liquid_glass_widgets/liquid_glass_widgets.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // Pre-warm shaders and Impeller pipeline await LiquidGlassWidgets.initialize(); // Optionally disable performance monitor // await LiquidGlassWidgets.initialize(enablePerformanceMonitor: false); runApp(LiquidGlassWidgets.wrap(const MyApp())); } ``` ``` -------------------------------- ### Configure GlassTabBar Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Basic setup for a GlassTabBar, specifying tabs, selected index, and callback for tab selection. ```dart GlassTabBar( tabs: ['Overview', 'Details', 'Reviews', 'Related'], selectedIndex: _tabIndex, onTabSelected: (index) => setState(() => _tabIndex = index), height: 44, quality: GlassQuality.standard, ) ``` -------------------------------- ### Add liquid_glass_widgets to pubspec.yaml Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Add this dependency to your pubspec.yaml file and run `flutter pub get` to install the package. ```yaml dependencies: liquid_glass_widgets: ^0.10.9 ``` -------------------------------- ### GlassSearchBar Example Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Implement a search input field with a glass effect using GlassSearchBar. Supports placeholder text, change handlers, and submission callbacks. ```dart GlassSearchBar( controller: _searchController, placeholder: 'Search...', onChanged: (query) => filterResults(query), onSubmitted: (query) => performSearch(query), ) ``` -------------------------------- ### Implement GlassBottomBar Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Example of integrating GlassBottomBar into a Flutter application, configuring tabs, appearance, and interaction. ```dart class MyHomePage extends StatefulWidget { @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { int _selectedIndex = 0; @override Widget build(BuildContext context) { return Scaffold( body: _pages[_selectedIndex], bottomNavigationBar: GlassBottomBar( tabs: [ GlassBottomBarTab( label: 'Home', icon: const Icon(CupertinoIcons.home), activeIcon: const Icon(CupertinoIcons.home_fill), glowColor: Colors.blue, ), GlassBottomBarTab( label: 'Search', icon: const Icon(CupertinoIcons.search), glowColor: Colors.purple, ), GlassBottomBarTab( label: 'Profile', icon: const Icon(CupertinoIcons.person), activeIcon: const Icon(CupertinoIcons.person_fill), glowColor: Colors.pink, ), ], selectedIndex: _selectedIndex, onTabSelected: (index) => setState(() => _selectedIndex = index), barHeight: 64, spacing: 8, horizontalPadding: 20, glassSettings: const LiquidGlassSettings( thickness: 30, blur: 3, refractiveIndex: 1.59, ), // Optional extra button for primary actions extraButton: GlassBottomBarExtraButton( icon: const Icon(CupertinoIcons.add), label: 'Create', onTap: () => showCreateDialog(), size: 64, ), ), ); } } ``` -------------------------------- ### Run flutter pub get Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Execute this command in your terminal after updating the pubspec.yaml file to fetch the new dependency. ```bash flutter pub get ``` -------------------------------- ### Get Dependencies Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/example/README.md Fetch project dependencies using Flutter's package manager. ```bash flutter pub get ``` -------------------------------- ### GlassAppBar Example Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Implement a glass morphism app bar using `GlassAppBar`, which supports titles, leading widgets, and actions. It implements `PreferredSizeWidget` for use in `Scaffold.appBar`. The `quality` parameter can be set for static surfaces. ```dart Scaffold( appBar: GlassAppBar( title: const Text('My App'), leading: GlassButton( icon: const Icon(Icons.arrow_back), onTap: () => Navigator.pop(context), ), actions: [ GlassButton( icon: const Icon(Icons.search), onTap: () => showSearch(), ), GlassButton( icon: const Icon(Icons.more_horiz), onTap: () => showMenu(), ), ], centerTitle: true, // iOS-style centered title quality: GlassQuality.premium, // Full shader pipeline for static surfaces ), body: const Center(child: Text('Content')), ) ``` -------------------------------- ### GlassContainer Example Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Utilize GlassContainer as a base for custom glass-effect containers. Specify dimensions, padding, shape, and quality. ```dart GlassContainer( width: 200, height: 100, padding: const EdgeInsets.all(16), shape: const LiquidRoundedSuperellipse(borderRadius: 12), quality: GlassQuality.standard, child: const Center(child: Text('Custom Container')), ) ``` -------------------------------- ### Create GlassButton (Icon) Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Example of a simple GlassButton used as an icon button with an accessibility label. ```dart // Icon button with default styling GlassButton( icon: const Icon(CupertinoIcons.heart), onTap: () => print('Favorite'), label: 'Add to favorites', // Accessibility label ) ``` -------------------------------- ### Wrap App with LiquidGlassWidgets for Backdrop Sharing Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Use LiquidGlassWidgets.wrap() in main.dart to install root backdrop sharing and accessibility. Pass adaptiveQuality: true for automatic quality tuning. For multi-screen apps, add GlassBackdropScope to each route. ```dart runApp(LiquidGlassWidgets.wrap(child: const MyApp(), adaptiveQuality: true)); ``` -------------------------------- ### Wrap App with Liquid Glass Infrastructure Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Use `LiquidGlassWidgets.wrap()` to integrate your app with the library's scopes, enabling shared GPU backdrop capture and adaptive quality. This can reduce blit costs when multiple glass widgets are visible. Examples show zero-config, adaptive quality, and full configuration with persistent quality settings. ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); await LiquidGlassWidgets.initialize(); // Zero-config setup (most apps) runApp(LiquidGlassWidgets.wrap(const MyApp())); // With adaptive quality for Android/broad device support runApp(LiquidGlassWidgets.wrap( const MyApp(), adaptiveQuality: true, )); // Full configuration with persistent quality settings final prefs = await SharedPreferences.getInstance(); final savedQuality = prefs.getString('glass_quality'); final initialQuality = savedQuality != null ? GlassQuality.values.byName(savedQuality) : null; runApp(LiquidGlassWidgets.wrap( const MyApp(), respectSystemAccessibility: true, // Default: respects OS settings adaptiveQuality: true, adaptiveConfig: GlassAdaptiveScopeConfig( initialQuality: initialQuality ?? GlassQuality.standard, allowStepUp: true, onQualityChanged: (from, to) => prefs.setString('glass_quality', to.name), ), )); } ``` -------------------------------- ### Initialize LiquidGlassWidgets in main.dart Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Call `LiquidGlassWidgets.initialize()` before `runApp()` to pre-cache shaders and register the debug performance monitor. Then, wrap your app with `LiquidGlassWidgets.wrap()` to install the root backdrop scope and accessibility bridge. ```dart import 'package:flutter/material.dart'; import 'package:liquid_glass_widgets/liquid_glass_widgets.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // Async platform setup: shader prewarming + Impeller pipeline. await LiquidGlassWidgets.initialize(); // Widget-tree composition: installs GlassBackdropScope (required). // Enable adaptiveQuality to automatically tune glass quality per device. runApp(LiquidGlassWidgets.wrap( child: const MyApp(), adaptiveQuality: true, )); } ``` -------------------------------- ### GlassDialog Examples Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Show modal dialogs with a liquid glass effect using GlassDialog. Supports custom titles, messages, actions, and content. Actions are laid out intelligently. ```dart // Basic confirmation dialog GlassDialog.show( context: context, title: 'Delete Item?', message: 'This action cannot be undone.', actions: [ GlassDialogAction( label: 'Cancel', onPressed: () => Navigator.pop(context), ), GlassDialogAction( label: 'Delete', isDestructive: true, onPressed: () { deleteItem(); Navigator.pop(context); }, ), ], ); ``` ```dart // Three-action dialog with primary action final result = await GlassDialog.show( context: context, title: 'Save Changes?', message: 'You have unsaved changes.', actions: [ GlassDialogAction( label: "Don't Save", onPressed: () => Navigator.pop(context, false), ), GlassDialogAction( label: 'Cancel', onPressed: () => Navigator.pop(context), ), GlassDialogAction( label: 'Save', isPrimary: true, onPressed: () => Navigator.pop(context, true), ), ], ); ``` ```dart // Custom content dialog GlassDialog.show( context: context, title: 'Enter Name', content: Padding( padding: const EdgeInsets.symmetric(vertical: 16), child: GlassTextField( controller: _nameController, placeholder: 'Your name', ), ), actions: [ GlassDialogAction(label: 'Cancel', onPressed: () => Navigator.pop(context)), GlassDialogAction(label: 'OK', isPrimary: true, onPressed: () => submit()), ], settings: const LiquidGlassSettings(thickness: 40, blur: 15), ); ``` -------------------------------- ### GlassCard Examples Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Use GlassCard for creating visually appealing cards with a glass effect. Customize padding, shape, and whether it uses its own layer for effects. ```dart GlassCard( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Card Title', style: TextStyle(fontWeight: FontWeight.bold)), SizedBox(height: 8), Text('Card content goes here with some description text.'), ], ), padding: const EdgeInsets.all(16), quality: GlassQuality.standard, ) ``` ```dart GlassCard( padding: EdgeInsets.zero, clipBehavior: Clip.antiAlias, shape: const LiquidRoundedSuperellipse(borderRadius: 20), child: Image.network('https://example.com/image.jpg', fit: BoxFit.cover), ) ``` ```dart GlassCard( useOwnLayer: true, settings: const LiquidGlassSettings( thickness: 30, blur: 10, ), child: ListTile( title: Text('Setting Item'), trailing: Icon(Icons.chevron_right), ), ) ``` -------------------------------- ### GlassTextField Examples Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Use GlassTextField for text input with a glass effect. Configure keyboard type, input actions, icons, and interaction behaviors. Supports multiline input. ```dart GlassTextField( controller: _emailController, placeholder: 'Email address', keyboardType: TextInputType.emailAddress, textInputAction: TextInputAction.next, prefixIcon: const Icon(Icons.email, size: 20, color: Colors.white70), onChanged: (value) => validateEmail(value), onSubmitted: (value) => submitForm(), // iOS 26 interaction behavior interactionBehavior: GlassInteractionBehavior.full, // Glow + scale pressScale: 1.03, glowColor: const Color(0x1FFFFFFF), quality: GlassQuality.standard, ) ``` ```dart GlassTextField( controller: _passwordController, placeholder: 'Password', obscureText: true, suffixIcon: Icon( _showPassword ? Icons.visibility_off : Icons.visibility, size: 20, color: Colors.white70, ), onSuffixTap: () => setState(() => _showPassword = !_showPassword), ) ``` ```dart GlassTextField( placeholder: 'Enter your message...', maxLines: 5, minLines: 3, ) ``` -------------------------------- ### Show Gradual Dark Transition Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Configures a modal sheet to have a gradual dark transition effect, starting at 40% fill threshold and expanding to a black color. ```dart GlassModalSheet.show( context: context, fillThreshold: 0.4, fillTransition: FillTransition.gradual, expandedColor: Colors.black, builder: (context) => DarkUI(), ); ``` -------------------------------- ### LiquidGlassSettings Parameters Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Internal Material Recipe for LiquidGlassSettings, detailing parameters, types, defaults, and their functions. ```markdown | Parameter | Type | Default | What it does | | :--- | :--- | :--- | :--- | | `blur` | `double` | `10.0` | Frosting intensity. Lerps to `0.0` in solid state. | | `thickness` | `double` | `10.0` | Depth of the glass. Affects how much the rim catches light. | | `refractiveIndex` | `double` | `0.15` | Edge highlight intensity. Specifically tuned for iOS 26. | | `chromaticAberration`| `double` | `0.0` | Rainbow fringing. Disabled by default for sheet performance. | | `saturation` | `double` | `1.2` | Background color boost. Pulses during touch interaction. | | `lightIntensity` | `double` | `0.7` | Brightness of the specular rim (top/left highlight). | | `lightAngle` | `double` | `2.356` | 135 degrees (upper-left). Standard iOS lighting. | | `ambientStrength` | `double` | `0.4` | Baseline brightness of the glass surface. | | `glassColor` | `Color` | `0x1FFFFFFF`| 12% White tint (iOS 26 standard). | ``` -------------------------------- ### Run All Tests Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Execute all tests in the project. ```bash flutter test ``` -------------------------------- ### Initialize and Configure Adaptive Quality Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Load previously settled quality to avoid warmup jank on repeat launches. Persist quality changes using onQualityChanged. ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); // Load previously settled quality — avoids warmup jank on repeat launches. final prefs = await SharedPreferences.getInstance(); final saved = prefs.getString('glass_quality'); final initial = saved != null ? GlassQuality.values.byName(saved) // Dart 2.15+ built-in : null; // null = run Phase 2 on first launch, then persist await LiquidGlassWidgets.initialize(); runApp(LiquidGlassWidgets.wrap( child: const MyApp(), adaptiveQuality: true, adaptiveConfig: GlassAdaptiveScopeConfig( initialQuality: initial, // restore immediately — no warmup window allowStepUp: true, // allow recovery after thermal throttle onQualityChanged: (_, to) => // persist whenever quality settles prefs.setString('glass_quality', to.name), ), )); } ``` -------------------------------- ### Initialize Liquid Glass Widgets Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Call LiquidGlassWidgets.initialize() at application startup to pre-cache shaders and prevent a white flash on the first render. ```dart LiquidGlassWidgets.initialize() ``` -------------------------------- ### Initialize Liquid Glass Widgets Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Initialize the Liquid Glass Widgets library. The performance monitor is auto-enabled in debug/profile builds and has zero cost in release builds. ```dart // Default — auto-enabled in debug/profile, zero-cost in release await LiquidGlassWidgets.initialize(); ``` ```dart // Opt out entirely await LiquidGlassWidgets.initialize(enablePerformanceMonitor: false); ``` -------------------------------- ### Configure Adaptive Quality with GlassAdaptiveScope Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Enable automatic quality adaptation by wrapping your app with LiquidGlassWidgets.wrap(adaptiveQuality: true). For per-screen control, use GlassAdaptiveScope with initialQuality and allowStepUp parameters. The experimental warmup thresholds can be adjusted for specific device performance tuning. ```dart GlassAdaptiveScopeConfig( debugLogDiagnostics: true, // prints to console in debug builds only ) ``` ```dart GlassAdaptiveScopeConfig( onDiagnostic: (d) { // d.reason, d.p75Ms, d.p95Ms, d.framesMeasured, d.phase are all set debugPrint('📊 ${d.from.name} → ${d.to.name} | reason: ${d.reason.name} | P75: ${d.p75Ms?.toStringAsFixed(1)}ms'); }, ) ``` ```dart GlassAdaptiveScope( initialQuality: GlassQuality.standard, // conservative start allowStepUp: true, // Android calibration — raise if your device is incorrectly demoted to standard. // Post your P75 + device model to the Threshold Calibration Discussion! // warmupPremiumThresholdMs: 24.0, // default 20.0 // warmupStandardThresholdMs: 32.0, // default 28.0 child: Scaffold(...), ) ``` -------------------------------- ### Show Classic iOS Modal Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Demonstrates how to display a classic dismissible modal sheet with an initial half-expanded state. ```dart GlassModalSheet.show( context: context, initialState: SheetState.half, mode: SheetMode.dismissible, builder: (context) => MyContent(), ); ``` -------------------------------- ### Create GlassButton (Custom Content) Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Demonstrates creating a GlassButton with custom child widgets, suitable for complex button designs. ```dart // Custom content button GlassButton.custom( onTap: () => print('Submit'), width: 120, height: 48, child: const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(CupertinoIcons.paperplane, size: 16), SizedBox(width: 8), Text('Send', style: TextStyle(color: Colors.white)), ], ), ) ``` -------------------------------- ### Initialize Liquid Glass Widgets Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Call `LiquidGlassWidgets.initialize()` once in `main()` before `runApp` to pre-warm shaders and compile the Impeller pipeline. This prevents the initial white flash on first render. The performance monitor is automatically enabled in debug/profile builds. ```dart import 'package:flutter/material.dart'; import 'package:liquid_glass_widgets/liquid_glass_widgets.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // Pre-warm shaders and Impeller pipeline // Performance monitor is auto-enabled in debug/profile builds await LiquidGlassWidgets.initialize(); // Optionally disable performance monitor // await LiquidGlassWidgets.initialize(enablePerformanceMonitor: false); runApp(LiquidGlassWidgets.wrap(const MyApp())); } ``` -------------------------------- ### Configure GlassSlider Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Basic implementation of a GlassSlider for value selection, showing min, max, and value binding. ```dart GlassSlider( value: _volume, onChanged: (value) => setState(() => _volume = value), min: 0.0, max: 100.0, ) ``` -------------------------------- ### Wrap Screen in GlassBackdropScope Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Wrap each screen in GlassBackdropScope to force a fresh GPU backdrop capture on mount, preventing ghost artifacts when navigating between screens. ```dart class MyNewPage extends StatelessWidget { @override Widget build(BuildContext context) { return GlassBackdropScope( // ← forces a fresh capture on mount child: Scaffold( appBar: GlassAppBar(title: const Text('New Page')), body: ..., bottomNavigationBar: GlassBottomBar(...), ), ); } } ``` -------------------------------- ### Create GlassButton (Standalone Layer) Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Shows how to use GlassButton with its own layer for premium quality, including interaction and glow effect customization. ```dart // Standalone button with own layer (required for premium quality outside layers) GlassButton( icon: const Icon(CupertinoIcons.play), onTap: () => playVideo(), useOwnLayer: true, quality: GlassQuality.premium, settings: const LiquidGlassSettings( thickness: 30, blur: 10, ), // Interaction customization interactionScale: 1.05, // 5% scale on press stretch: 0.5, // Jelly stretch amount glowColor: Colors.blue.withOpacity(0.4), glowRadius: 1.5, ) ``` -------------------------------- ### Sync Renderer Script Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/lib/src/renderer/RENDERER_ATTRIBUTION.md Use this bash script to update the vendored renderer with new upstream releases. It automates copying files, syncing shaders, and staging changes for manual review. ```bash ./tools/sync_renderer.sh # e.g. ./tools/sync_renderer.sh 0.2.0-dev.5 ``` -------------------------------- ### Show Minimalist Settings List Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Displays a modal sheet with a minimalist glass quality and no margins or border radius, suitable for settings lists. ```dart GlassModalSheet.show( context: context, horizontalMargin: 0, bottomMargin: 0, topBorderRadius: 16, quality: GlassQuality.minimal, builder: (context) => SettingsList(), ); ``` -------------------------------- ### Configure Scrollable Content Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Shows how to integrate a ListView with a ScrollControllerProvider to enable responsive scroll synchronization within a modal sheet. ```dart final scroll = ScrollControllerProvider.of(context); return ListView( controller: scroll?.controller, physics: scroll?.physics, children: [...], ); ``` -------------------------------- ### Configure Global Glass Theme Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Sets up a global theming system for glass widgets, supporting light and dark mode variants with customizable settings. Access the current theme variant using GlassThemeData.of(context).variantFor(context). ```dart GlassTheme( data: GlassThemeData( light: GlassThemeVariant( settings: GlassThemeSettings( thickness: 30, blur: 12, glassColor: const Color(0x4AD2DCF0), // Cool blue-white tint ), quality: GlassQuality.standard, ), dark: GlassThemeVariant( settings: GlassThemeSettings( thickness: 50, blur: 18, glassColor: Colors.white24, ), quality: GlassQuality.premium, ), ), child: MaterialApp( home: MyHomePage(), ), ) ``` ```dart // Access current theme variant final variant = GlassThemeData.of(context).variantFor(context); ``` -------------------------------- ### Internal Rendering Stack Diagram Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md The _SheetLayout builds a complex stack of 4 distinct glass-aware layers to achieve its high-fidelity look. ```mermaid graph TD A["Scaffold Background (e.g. Map)"] --> B["Interaction Listener"] B --> C["Positioned Box (Dynamic Metrics)"] C --> D["LiquidStretch (Rubber-banding)"] D --> E["Layer 1: Background Shadow & Solid Color"] D --> F["Layer 2: AdaptiveGlass (Backdrop Blur)"] D --> G["Layer 3: GlassGlow (Tactile Glare)"] G --> H["Layer 4: AdaptiveLiquidGlassLayer (Content Glass)"] H --> I["ClipPath (RoundedSuperellipse Clipping)"] I --> J["Primary Content Payload"] I --> K["Drag Handle (Handle Zone)"] ``` -------------------------------- ### Consolidate Highlight Color Implementation Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/lib/src/renderer/RENDERER_ATTRIBUTION.md Replaced an inline highlight color block with a call to `getHighlightColor()` from `render.glsl`. This reduces code duplication and improves maintainability. ```glsl // Replaced 8-line inline highlight colour block with a call to `getHighlightColor()` // from `render.glsl`, which is already `#include`d by the same shader. ``` -------------------------------- ### Run App with Impeller Enabled Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/example/README.md Execute the Flutter application with the Impeller rendering engine enabled for optimized performance. ```bash flutter run --enable-impeller ``` -------------------------------- ### Configure Custom Performance Monitor Thresholds Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Customize the raster budget and sustained frame threshold for the performance monitor. ```dart GlassPerformanceMonitor.rasterBudget = const Duration(microseconds: 8333); // 120 fps GlassPerformanceMonitor.sustainedFrameThreshold = 120; ``` -------------------------------- ### Set Glass Quality Modes Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Choose from three quality tiers (standard, premium, minimal) to balance visual fidelity with performance. 'Minimal' uses only BackdropFilter for zero custom shader cost. ```dart // Standard - Default, works everywhere including scrollable lists GlassContainer( quality: GlassQuality.standard, child: const Text('Great for scrollable content'), ) ``` ```dart // Premium - Full Impeller shader pipeline, best for static surfaces GlassAppBar( quality: GlassQuality.premium, title: const Text('Static header'), ) ``` ```dart // Minimal - Zero custom shader cost, uses BackdropFilter only GlassCard( quality: GlassQuality.minimal, child: const Text('No shader overhead'), ) ``` -------------------------------- ### Show GlassToast Notifications Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Demonstrates how to display temporary notifications with different types, actions, and configurations. Use GlassSnackBar for Material Design naming. ```dart // Basic success toast GlassToast.show( context, message: 'Settings saved successfully', type: GlassToastType.success, ); ``` ```dart // Error toast with retry action GlassToast.show( context, message: 'Failed to save changes', type: GlassToastType.error, action: GlassToastAction( label: 'Retry', onPressed: () => saveChanges(), ), ); ``` ```dart // Info toast at top with custom icon GlassToast.show( context, message: 'New message received', type: GlassToastType.info, icon: const Icon(CupertinoIcons.envelope), position: GlassToastPosition.top, duration: const Duration(seconds: 5), ); ``` ```dart // Manual dismiss control final dismiss = GlassToast.show( context, message: 'Processing...', type: GlassToastType.neutral, duration: Duration.zero, // Won't auto-dismiss dismissible: true, ); // Later: dismiss(); ``` ```dart // GlassSnackBar is an alias for Material Design naming GlassSnackBar.show(context, message: 'Item added to cart'); ``` -------------------------------- ### Show Hero Section with Premium Quality Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Renders a modal sheet with premium quality settings, forcing a specular rim and applying custom glass effect settings like blur, chromatic aberration, and saturation. ```dart GlassModalSheet.show( context: context, quality: GlassQuality.premium, forceSpecularRim: true, settings: LiquidGlassSettings( blur: 40, chromaticAberration: 0.06, saturation: 1.8, ), builder: (context) => HeroBanner(), ); ``` -------------------------------- ### Premium Glass Quality Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Enable the full Impeller shader pipeline with texture capture and chromatic aberration using `GlassQuality.premium`. This mode is recommended only for static, non-scrolling surfaces like app bars, as it may not render correctly in scrollable views on Impeller. ```dart GlassAppBar( quality: GlassQuality.premium, title: const Text('Static header'), ) ``` -------------------------------- ### Provide Refraction Source with LiquidGlassScope Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt On Skia/Web platforms, `LiquidGlassScope` provides the refraction source for interactive widgets. Use the `stack` shorthand for the common wallpaper-behind-content pattern. ```dart // Shorthand for wallpaper-behind-content pattern LiquidGlassScope.stack( background: Image.asset('assets/wallpaper.jpg', fit: BoxFit.cover), content: Scaffold( body: Center( child: GlassSegmentedControl( segments: ['Option A', 'Option B', 'Option C'], selectedIndex: 0, onSegmentSelected: (i) {}, quality: GlassQuality.standard, ), ), ), ) ``` ```dart // Manual control over refraction source LiquidGlassScope( child: Stack( children: [ Positioned.fill( child: GlassRefractionSource( child: Image.asset('assets/wallpaper.jpg'), ), ), Center(child: GlassSegmentedControl(/* ... */)), ], ), ) ``` -------------------------------- ### Control Modal Sheet State Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Demonstrates programmatic control of a modal sheet's state using a controller, allowing snapping to a specific state like 'full' upon task completion. ```dart final controller = GlassModalSheetController(); // ... onComplete: () => controller.snapToState(SheetState.full); ``` -------------------------------- ### Minimal Glass Quality Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Utilize `GlassQuality.minimal` for a shader-free experience, ideal for older devices or when managing GPU budget. It uses `BackdropFilter` blur and a Rec. 709 saturation matrix, offering a frosted panel appearance with zero custom fragment shader cost. ```dart GlassCard( quality: GlassQuality.minimal, child: const Text('No shader overhead'), ) ``` -------------------------------- ### Show Always-on Music Player Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Configures a persistent modal sheet to act as an always-on mini-player, showing only its peek state. ```dart GlassModalSheet.show( context: context, initialState: SheetState.peek, mode: SheetMode.persistent, peekSize: 80, // Height of the mini-player builder: (context) => MiniPlayer(), ); ``` -------------------------------- ### Shorthand Liquid Glass Scope for Wallpaper Background Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Use this shorthand for the common pattern of placing wallpaper behind your Scaffold. It automatically handles the background image and content layering. ```dart LiquidGlassScope.stack( background: Image.asset('assets/wallpaper.jpg', fit: BoxFit.cover), content: Scaffold( body: Center( child: GlassSegmentedControl( segments: const ['Option A', 'Option B', 'Option C'], selectedIndex: 0, onSegmentSelected: (i) {}, quality: GlassQuality.standard, ), ), ), ) ``` -------------------------------- ### Isolate Backdrop Capture with GlassBackdropScope Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Wrap each route or screen that hosts glass surfaces with `GlassBackdropScope` to prevent ghost artifacts during navigation. This ensures isolated backdrop capture per screen. ```dart class MyNewPage extends StatelessWidget { @override Widget build(BuildContext context) { return GlassBackdropScope( child: Scaffold( appBar: GlassAppBar(title: const Text('New Page')), body: const Center(child: Text('Content')), bottomNavigationBar: GlassBottomBar(/* ... */), ), ); } } ``` -------------------------------- ### Apply Global Glass Theme Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Customize glass widget appearance globally by wrapping your app with `GlassTheme`. Define `GlassThemeVariant` for light and dark modes, specifying `GlassThemeSettings` for properties like `thickness` and `blur`, and `GlassQuality`. ```dart GlassTheme( data: GlassThemeData( light: GlassThemeVariant( settings: GlassThemeSettings(thickness: 30, blur: 12), quality: GlassQuality.standard, ), dark: GlassThemeVariant( settings: GlassThemeSettings(thickness: 50, blur: 18), quality: GlassQuality.premium, ), ), child: MaterialApp(home: MyHomePage()), ) ``` -------------------------------- ### Drive Glass Specular Highlights with GlassMotionScope Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Utilize `GlassMotionScope` to drive the glass specular highlight angle from any `Stream`, such as device gyroscope data. This enables dynamic lighting effects based on motion. ```dart import 'package:sensors_plus/sensors_plus'; GlassMotionScope( stream: gyroscopeEvents.map((e) => e.y * 0.5), child: Scaffold( appBar: GlassAppBar(title: const Text('Dynamic Lighting')), body: const MyContent(), ), ) ``` -------------------------------- ### Synchronize List Scrolling with Sheet Dragging Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Use the provided scroll controller to sync list scrolling with sheet dragging for a seamless experience. Ensure smooth snapping by using the provided physics. ```dart final scrollData = ScrollControllerProvider.of(context); return ListView( controller: scrollData?.controller, // Syncs list scrolling with sheet dragging physics: scrollData?.physics, // Ensures smooth snapping children: [...], ); ``` -------------------------------- ### Grouped Mode with LiquidGlassLayer Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/example/README.md Utilize AdaptiveLiquidGlassLayer for improved performance when multiple glass widgets share a layer. This is the recommended approach. ```dart AdaptiveLiquidGlassLayer( settings: LiquidGlassSettings(...), child: Column( children: [ GlassButton(...), GlassCard(...), ], ), ) ``` -------------------------------- ### Standard Glass Quality Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Use `GlassQuality.standard` for most use cases, providing iOS 26-accurate glass effects on all platforms. This is the default quality setting. ```dart GlassContainer( quality: GlassQuality.standard, // this is the default child: const Text('Great for scrollable content'), ) ``` -------------------------------- ### Configure Glass Glow Colors in Theme Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Set the primary glow color, blur radius, spread radius, and opacity for all glass surfaces by defining GlassGlowColors within GlassThemeVariant. Individual widgets can override these theme settings. ```dart GlassThemeVariant( glowColors: GlassGlowColors( primary: Colors.blue, // tab indicator & search pill glow blurRadius: 12, // glow softness (default: 0 = crisp edge) spreadRadius: 0.2, // glow spread beyond the widget edge (default: 0) opacity: 0.8, // overall glow intensity (default: 1.0) ), ) ``` -------------------------------- ### Configure Liquid Glass Appearance Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt Defines the visual appearance of glass effects, including thickness, blur, chromatic aberration, and lighting. Adjust parameters like `lightAngle` for different lighting effects. ```dart const LiquidGlassSettings( thickness: 30, // Glass thickness (depth effect) blur: 10, // Backdrop blur radius chromaticAberration: 0.3, // RGB split effect lightIntensity: 1.0, // Specular highlight strength refractiveIndex: 1.59, // Light bending amount saturation: 1.0, // Color saturation ambientStrength: 1.0, // Ambient light contribution lightAngle: 0.75 * pi, // 135 degrees - Apple standard upper-left glassColor: Color(0x3DFFFFFF), specularSharpness: GlassSpecularSharpness.medium, ) ``` -------------------------------- ### Gyroscope Lighting with GlassMotionScope Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Drives specular highlight angles using a stream, such as device gyroscope events. Connect any stream source like scroll position or mouse events. ```dart GlassMotionScope( stream: gyroscopeEvents.map((e) => e.y * 0.5), child: Scaffold( appBar: GlassAppBar(title: const Text('My App')), body: ..., ), ) ``` -------------------------------- ### Adaptive Radius Resolution Table Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md When topBorderRadius or bottomBorderRadius is null, the sheet automatically adapts to the device's physical screen curvature based on device type and context. ```markdown | Device Type / Context | Resolved Radius | Trigger Logic | | :--- | :--- | :--- | | **Desktop / Home Button iPhone** | `0.0` | `bottomSafeArea == 0` | | **iPhone Pro Max (Island)** | `64.0` | `height >= 900` or `topSafeArea >= 59` | | **iPhone Pro / Base (Island)**| `50.0` | `height >= 800` or `topSafeArea >= 54` | | **iPhone with Notch** | `44.0` | Standard iOS SafeArea | | **Android (Gesture Nav)** | `28.0` | `bottomSafeArea > 0` on Android | | **Theme Override** | `theme.radius` | Custom value set in `GlassThemeData` | ``` -------------------------------- ### Navigation and Surfaces - GlassAppBar Source: https://context7.com/sdegenaar/liquid_glass_widgets/llms.txt A glass morphism app bar implementing Apple's navigation bar design with support for title, leading widget, and trailing actions. ```APIDOC ## GlassAppBar ### Description A glass morphism app bar implementing Apple's navigation bar design with support for title, leading widget, and trailing actions. Implements `PreferredSizeWidget` for use in `Scaffold.appBar`. ### Method `GlassAppBar({...})` ### Parameters #### Common AppBar Parameters - **title** (Widget) - The title to display in the app bar. - **leading** (Widget) - Widget to display before the title. - **actions** (List) - Widgets to display after the title. - **centerTitle** (bool) - Whether to center the title. Defaults to `false` (iOS-style centered title is `true`). #### GlassAppBar Specific Parameters - **quality** (GlassQuality) - The quality mode for the glass effect. Options include `premium`, `standard`, `minimal`. ### Request Example ```dart Scaffold( appBar: GlassAppBar( title: const Text('My App'), leading: GlassButton( icon: const Icon(Icons.arrow_back), onTap: () => Navigator.pop(context), ), actions: [ GlassButton( icon: const Icon(Icons.search), onTap: () => showSearch(), ), GlassButton( icon: const Icon(Icons.more_horiz), onTap: () => showMenu(), ), ], centerTitle: true, // iOS-style centered title quality: GlassQuality.premium, // Full shader pipeline for static surfaces ), body: const Center(child: Text('Content')), ) ``` ``` -------------------------------- ### Animate UI Based on Sheet Expansion Progress Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Animate your widgets based on the sheet's expansion progress. The progress value ranges from 0.0 (Peek) to 1.0 (Full). ```dart final state = GlassModalSheetStateProvider.of(context); final progress = state?.progress ?? 0.0; // 0.0 (Peek) to 1.0 (Full) return Opacity( opacity: progress, // Fade in content as the sheet expands child: MyComplexWidget(), ); ``` -------------------------------- ### Run macOS Golden Tests Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Execute golden tests specifically on macOS, which requires Impeller. ```bash flutter test --tags golden ``` -------------------------------- ### Manual Liquid Glass Scope for Granular Refraction Control Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Provides granular control over which surface is sampled for liquid glass refraction. Useful when you need to precisely define the refraction source. ```dart LiquidGlassScope( child: Stack( children: [ Positioned.fill( child: GlassRefractionSource( child: Image.asset('assets/wallpaper.jpg'), ), ), Center(child: GlassSegmentedControl(...)), ], ), ) ``` -------------------------------- ### Control Specular Sharpness on Glass Surfaces Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Adjust the tightness of specular highlights on any glass surface using LiquidGlassSettings.specularSharpness. Options range from 'soft' (diffuse) to 'sharp' (mirror-like), with 'medium' as the default. ```dart GlassCard( settings: LiquidGlassSettings( specularSharpness: GlassSpecularSharpness.sharp, // tight, mirror-like ), child: ..., ) ``` -------------------------------- ### GlassModalSheetScaffold for Hit-Through Navigation Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/docs/assets/GLASS_MODAL_SHEETS_GUIDE.md Use GlassModalSheetScaffold for interactive backgrounds with modal sheets, ideal for persistent UI elements. It places background and sheet in the same stack, avoiding route transition overhead. ```dart return GlassModalSheetScaffold( background: MyInteractiveMap(), // This remains interactive! sheetChild: MySheetContent(), // The glass sheet on top initialState: SheetState.peek, mode: SheetMode.persistent, // ... other GlassModalSheet parameters ... ); ``` -------------------------------- ### Override System Accessibility Defaults with GlassAccessibilityScope Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/README.md Place this scope in your widget tree to override system accessibility defaults. It's useful for testing, showcases, or per-subtree customization. Reads system flags automatically. ```dart MaterialApp( builder: (context, child) => GlassAccessibilityScope( child: child!, // reads system flags automatically ), ) ``` ```dart GlassAccessibilityScope( reduceTransparency: true, child: GlassSettingsPreview(), ) ``` -------------------------------- ### Increase Shader Precision for Mobile Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/lib/src/renderer/RENDERER_ATTRIBUTION.md Changed shader precision from `mediump` to `highp` to avoid quantization banding on mobile devices. Mediump's limited mantissa can cause visible artifacts at typical thickness values. ```glsl precision highp float; ``` -------------------------------- ### Standalone Mode with GlassButton Source: https://github.com/sdegenaar/liquid_glass_widgets/blob/main/example/README.md Configure a GlassButton to use its own layer for rendering when not part of a shared LiquidGlassLayer. This is useful for individual widget customization. ```dart GlassButton( useOwnLayer: true, settings: LiquidGlassSettings(...), ... ) ```