🍹 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.
✨ 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, andLitchiTabBar. - 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.
🚀 Getting Started
Add glass_of_litchi to your pubspec.yaml:
dependencies:
glass_of_litchi: ^0.0.1
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. Copy Directly from Figma Glass (1:1 Match)
Match all standard Figma Glass effect options and Apple squircle continuous 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'),
)
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'),
],
)
4. 120 FPS High-Performance Feeds (LitchiScope)
Eliminate the multi-BackdropFilter GPU bottleneck in scrolling feeds with liteMode:
LitchiScope(
liteMode: true, // Zero redundant GPU passes — 120 FPS in scroll views
cornerSmoothing: 0.6, // Unified Apple continuous curvature
lightAngle: 135.0, // Unified physical scene lighting
child: ListView(
children: [
LitchiCard(...),
LitchiCard(...),
],
),
)
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:
LitchiCardandLitchiButtonactively 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 & iOSUIVisualEffectView), 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 intoshaderRefraction: trueon 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.
Libraries
- glass_of_litchi
- A dewy, organic glassmorphism and liquid glass UI kit for Flutter.