Skip to main content

glass_of_litchi 0.0.2 copy "glass_of_litchi: ^0.0.2" to clipboard
glass_of_litchi: ^0.0.2 copied to clipboard

A dewy, organic glassmorphism and liquid glass UI kit for Flutter featuring juicy fruit-toned presets, tactile highlights, and zero-setup components.

🍹 Glass of Litchi (glass_of_litchi) #

A dewy, organic glassmorphism and liquid glass UI kit for Flutter.

Instead of sterile, cold blur wrappers or hyper-complex shader configuration manuals, Glass of Litchi delivers artisanal, fruit-toned glass aesthetics with opinionated, gorgeous defaults and zero setup.

Glass of Litchi Hero Card


✨ Features #

  • Organic Fruit & Luxury Flavours: Pre-configured aesthetic presets (dewy, juicy, frosted, crystal, milkyLitchi, roseTint, goldenCitrus, liquidMercury, polarIce, smokedQuartz).
  • Tactile Specular Highlights: Multi-stop rim lighting gradients and ambient overhead specular sheen.
  • Apple Vibrancy & Saturation: Hardware Rec. 709 saturation boost (vibrancy) ensuring colors pop beneath frosted glass without washing out into gray.
  • Drop-in Component Suite: Ready-to-use LitchiCard, LitchiButton, LitchiChip, LitchiSegmentedControl, LitchiTextField, LitchiDialog, and LitchiTabBar.
  • High-FPS Fallback Strategy: Automatic smooth rendering fallback when blur is disabled or on low-end hardware.
  • 100% Universal Flutter: Works out of the box on Android, iOS, Web, macOS, Windows, and Linux. When running on backends with fragment shader support (Impeller / Skia), optical refraction runs directly on the GPU. On environments without custom shader support (e.g. Web HTML renderer), it automatically and gracefully falls back to hardware Gaussian blur and specular rim gradients.

🚀 Getting Started #

Add glass_of_litchi to your pubspec.yaml:

dependencies:
  glass_of_litchi: ^0.0.2

Import the package:

import 'package:glass_of_litchi/glass_of_litchi.dart';

🎨 Quick Usage #

1. Ready-to-use Glass Card (with Dual-Edge Angle) #

LitchiCard(
  flavour: LitchiFlavour.juicy,
  // 135° = Classic top-left to bottom-right dual-rim reflection
  lightAngle: 135.0, 
  onTap: () => print('Juicy glass tapped!'),
  child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: const [
      Text('Lychee Spritz', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
      SizedBox(height: 8),
      Text('Dewy, tactile, and translucent.'),
    ],
  ),
)

2. Figma Glass-Inspired Parameter Mapping (.fromFigma) #

Map intuitive Figma Glass design parameters and Apple continuous squircle curvature directly:

LitchiCard.fromFigma(
  lightAngle: 135.0,        // 0° to 360° (direction of key light)
  lightPercent: 85.0,       // 0% to 100% (specular peak brightness)
  refraction: 25.0,         // 0% to 100% (inner optical bevel bending)
  depth: 10.0,              // 0 to 50 px (3D slab thickness & drop shadow)
  dispersion: 35.0,         // 0% to 100% (chromatic rainbow rim fringing)
  frost: 26.0,              // 0% to 100% (matte blur roughness)
  splay: 50.0,              // 0% to 100% (specular highlight arc spread)
  cornerSmoothing: 0.6,     // 0.0 to 1.0 (Apple G2 continuous squircle)
  child: const Text('Exact Figma Clone'),
)

Figma 1:1 Glass Effect Inspector

3. Signature Floating Glass Tab Bar (LitchiTabBar) #

Floating navigation bar with an animated, sliding liquid glass squircle selection pill that squashes and stretches with spring physics:

LitchiTabBar(
  flavour: LitchiFlavour.dewy,
  selectedIndex: currentTab,
  onTabSelected: (index) => setState(() => currentTab = index),
  items: const [
    LitchiTabItem(icon: Icons.auto_awesome, label: 'Feed'),
    LitchiTabItem(icon: Icons.local_bar, label: 'Drinks', badgeText: 'NEW'),
    LitchiTabItem(icon: Icons.person_outline, label: 'Profile'),
  ],
)

Floating Glass Tab Bar

4. High-Performance Smooth Scrolling (LitchiScope) #

Eliminate the multi-BackdropFilter GPU bottleneck in scrolling feeds with liteMode:

LitchiScope(
  liteMode: true,            // Avoid redundant GPU saveLayer passes in scroll views
  cornerSmoothing: 0.6,      // Unified Apple continuous curvature
  lightAngle: 135.0,         // Unified physical scene lighting
  child: ListView(
    children: [
      LitchiCard(...),
      LitchiCard(...),
    ],
  ),
)

Liquid Stat Cards

Ambient Lo-Fi Glass Player

5. Tactile Glass Button #

LitchiButton.fromFigma(
  lightAngle: 135.0,
  lightPercent: 90.0,
  cornerSmoothing: 0.6,
  onPressed: () {},
  child: const Text('Refresh'),
)

6. Interactive Glass Chips (LitchiChip) #

Dewy, spring-animated glass pills for tags, filters, and choices:

LitchiChip(
  leading: const Icon(Icons.auto_awesome, size: 16),
  label: const Text('Juicy Pulp'),
  selected: isSelected,
  flavour: LitchiFlavour.dewy,
  selectedFlavour: LitchiFlavour.juicy,
  onSelected: (val) => setState(() => isSelected = val),
)

7. Sliding Segmented Control (LitchiSegmentedControl) #

Liquid glass inline selector with a sliding squircle indicator pill:

LitchiSegmentedControl<String>(
  selectedValue: currentMode,
  onValueChanged: (val) => setState(() => currentMode = val),
  segments: const [
    LitchiSegment(value: 'ice', label: Text('Ice Chilled'), icon: Icon(Icons.ac_unit)),
    LitchiSegment(value: 'ambient', label: Text('Ambient')),
    LitchiSegment(value: 'sparkling', label: Text('Sparkling'), badgeText: 'HOT'),
  ],
)

8. Frosted Glass Input (LitchiTextField) #

Dewy translucent text input with glowing specular rim focus transitions:

LitchiTextField(
  controller: searchController,
  hintText: 'Search glass beverages...',
  prefix: const Icon(Icons.search, size: 20),
  onChanged: (text) => filterItems(text),
)

9. Frosted Glass Dialog & Bottom Sheet (showLitchiDialog) #

Custom blurred scrim overlays with squircle spring entrance animations:

showLitchiDialog<void>(
  context: context,
  builder: (ctx) => LitchiDialog(
    title: const Text('Confirm Order? 🍹'),
    content: const Text('Fresh lychee spritzer with chilled dewy frost.'),
    actions: [
      TextButton(onPressed: () => Navigator.pop(ctx), child: const Text('Cancel')),
      LitchiButton(
        onPressed: () => Navigator.pop(ctx),
        child: const Text('Confirm'),
      ),
    ],
  ),
);

10. Core Primitive #

LitchiGlass.fromFigma(
  lightAngle: 135.0,
  frost: 25.0,
  dispersion: 20.0,
  cornerSmoothing: 0.6,
  child: const Text('Custom Container'),
)

11. Hardware GPU Fragment Shader Optics (Impeller) #

On devices running Flutter's Impeller engine, glass_of_litchi uses an embedded GLSL 460 fragment shader (shaders/refraction.frag) composed with ImageFilter.shader for live optical refraction and chromatic dispersion:

  • Wavelength Dispersion: Bends red and blue light rays at different angles along the glass perimeter, creating authentic optical fringing.
  • Rim Bevel Distortion: Curves and magnifies background pixels inward along the continuous squircle border.
  • Frosted Micro-Roughness / Anti-Banding Noise: Procedural screen-space stochastic grain eliminates color banding on OLED screens and adds tactile sandblasted texture (noise: 0% to 100%).
  • Dynamic Lighting & Shimmer: LitchiCard and LitchiButton actively shimmer their specular rims in real time responding to cursor hover (desktop/web) and spring touch-flex physics.
  • Flavour Morphing & Interpolation: Smoothly animate between glass presets using LitchiFlavour.lerp(a, b, t).
  • Zero-Delay Pre-caching & GPU Pipeline Warmup:
    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await LitchiGlass.precacheShaders(); // Compiles shader & warms GPU Pipeline State Object (PSO)
      runApp(const MyApp());
    }
    
  • Graceful Fallback: If fragment shaders are unavailable in the host environment (e.g., legacy Skia or headless test runners), it automatically and silently falls back to standard Gaussian blur and stochastic canvas grain.

💡 Apple-Aligned Local Refraction by Default (shaderRefraction: false): Following Apple's design principles (e.g. visionOS & iOS UIVisualEffectView), glass components default to hardware Gaussian blur and authentic G2 squircle rim highlights. This ensures the glass only refracts and diffuses whatever content is directly underneath itself, with zero cross-card bleed, zero whole-screen warping, and buttery 120 FPS performance in scrollable views (ListView, CustomScrollView). You can opt into shaderRefraction: true on static hero panels if experimental Impeller fragment shader chromatic aberration is desired.

12. Apple / visionOS Vibrancy Saturation Boost (vibrancy) #

Heavy Gaussian blur on standard glass can desaturate rich background artwork, photos, or starfields into a dull, muddy gray. Inspired by Apple's UIVibrancyEffect, glass_of_litchi composes a hardware-accelerated Rec. 709 luminance saturation matrix (createVibrancyMatrix) directly into the backdrop pipeline:

  • vibrancy: 1.0: Neutral, unadjusted color saturation.
  • vibrancy: 1.2 – 1.5: Rich chromatic saturation boost that lets cosmic nebulae, neon glows, and wallpaper hues pop vibrantly through the frosted glass.

🍓 Preset Flavours #

Flavour Characteristics Typical Use Case
dewy Crisp, high translucency, subtle white sheen (vibrancy: 1.15) Floating action bars, navbar headers
juicy Succulent lychee tint with rose-gold prismatic sheen (vibrancy: 1.40) Highlighted cards, hero CTAs, banners
frosted Velvety matte frost with wide Gaussian dispersion (vibrancy: 1.10) Background sheets, overlays, dialogs
crystal Ultra-clear refraction rim with minimal diffusion (vibrancy: 1.25) Badges, pills, chip selectors
milkyLitchi Creamy dessert undertone, semi-opaque (vibrancy: 1.05) Dark mode contrast, readable reading cards
roseTint Dusky rose petal glow with dual-rim sheen (vibrancy: 1.30) Romantic or luxury lifestyle accents
goldenCitrus Sun-kissed golden citrus glaze with nectar accents (vibrancy: 1.35) Warning alerts, rewards, sunny highlights
liquidMercury Liquid chrome/mercury, high metallic reflectivity (vibrancy: 1.15) Premium luxury badges, dark chrome CTAs
polarIce Glacial ice crystal, high dispersion cyan fringing (vibrancy: 1.40) Electric frosty badges, winter/ice accents
smokedQuartz Rich smoky bronze obsidian for OLED dark modes (vibrancy: 1.25) Velvet dark-mode reading cards, bottom sheets

📜 License #

MIT License. Crafted with ❤️ by Cavern Labs.

2
likes
160
points
432
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A dewy, organic glassmorphism and liquid glass UI kit for Flutter featuring juicy fruit-toned presets, tactile highlights, and zero-setup components.

Repository (GitHub)
View/report issues

Topics

#glassmorphism #ui #design-system #blur #liquid-glass

License

MIT (license)

Dependencies

flutter, material_ui

More

Packages that depend on glass_of_litchi