ambient_backdrop_glow
β¨ Why ambient_backdrop_glow?
Most ambient lighting implementations in Flutter suffer from two major problems:
- The Muddy Gray Midtone Problem: Naive RGB/sRGB color cross-fading produces desaturated, dirty gray transitions when switching between complementary artwork colors (e.g. pink to cyan).
ambient_backdrop_glowuses the OKLab color space to ensure smooth, constant perceived lightness and chromatic vibrancy. - UI Thread Jank: Extracting color histograms from high-resolution images often drops frames.
AmbientColorExtractorautomatically downsamples onto offscreen buffers and quantizes colors in under 4ms with zero frame drops.
π Features
- π΅ 4 Ambient Glow Modes:
AmbientGlowMode.meshβ Multi-point fluid harmonic mesh gradient (Apple Music & modern media player style).AmbientGlowMode.radialβ Focused top-weighted or centered glow.AmbientGlowMode.auroraβ Dual-wave atmospheric light flow.AmbientGlowMode.spotlightβ Direct backlight centered behind product/album cards.
- π¨ Automatic Palette Extraction: Pass any
ImageProvider(Network, Asset, Memory, File) and the dominant, vibrant, and secondary colors are extracted automatically. - π Perceptual OKLab Transitions: Animated cross-fades between tracks or screens blend with rich color saturation rather than dull gray artifacts.
- β‘ GPU-Accelerated: High-efficiency
CustomPainterwith hardware Gaussian blur shaders. - π All 6 Platforms Supported: 100% pure Dart & Flutter with zero native C/C++ dependencies. Runs on Android, iOS, Web, macOS, Windows, and Linux.
π¦ Installation
Add ambient_backdrop_glow to your pubspec.yaml:
dependencies:
ambient_backdrop_glow: ^1.1.2
Or run:
flutter pub add ambient_backdrop_glow
π‘ Quick Start
1. Dynamic Glow from Album Artwork (Network / Asset Image)
import 'package:flutter/material.dart';
import 'package:ambient_backdrop_glow/ambient_backdrop_glow.dart';
class MusicPlayerScreen extends StatelessWidget {
final String albumArtUrl = 'https://images.unsplash.com/photo-1614613535308-eb5fbd3d2c17';
const MusicPlayerScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: AmbientBackdropGlow(
image: NetworkImage(albumArtUrl),
mode: AmbientGlowMode.mesh,
style: const AmbientGlowStyle(
blurSigma: 50.0,
intensity: 0.85,
speed: 1.0,
),
child: SafeArea(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Image.network(albumArtUrl, width: 280, height: 280, fit: BoxFit.cover),
),
const SizedBox(height: 24),
const Text(
'Midnight Reverie',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.white),
),
const Text(
'Solaris Duo',
style: TextStyle(fontSize: 14, color: Colors.white70),
),
],
),
),
),
),
);
}
}
2. Custom Neon Palette Backdrop
AmbientBackdropGlow(
colors: const [
Color(0xFF6366F1), // Indigo
Color(0xFFEC4899), // Pink
Color(0xFF06B6D4), // Cyan
],
mode: AmbientGlowMode.aurora,
style: const AmbientGlowStyle(
blurSigma: 60.0,
intensity: 0.9,
),
child: YourContentWidget(),
)
π οΈ API Reference
AmbientBackdropGlow Properties
| Property | Type | Default | Description |
|---|---|---|---|
image |
ImageProvider? |
null |
Source image for dynamic color extraction. |
colors |
List<Color>? |
null |
Direct custom colors for ambient mesh points. |
palette |
AmbientColorPalette? |
null |
Pre-configured structured color palette. |
mode |
AmbientGlowMode |
AmbientGlowMode.mesh |
Glow style (mesh, radial, aurora, spotlight). |
style |
AmbientGlowStyle |
AmbientGlowStyle() |
Blur sigma, intensity, spread multiplier, speed. |
crossFadeDuration |
Duration |
Duration(milliseconds: 800) |
Cross-fade duration when artwork changes. |
overlay |
Widget? |
null |
Optional scrim/frosted glass overlay between backdrop and child. |
child |
Widget? |
null |
Foreground content placed on top of the ambient glow. |
π Support the Project
If you find this project useful, consider supporting its active maintenance and future development:
π License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Maintained with β€οΈ by Govind Tank.
Libraries
- ambient_backdrop_glow
- Dynamic ambient backdrop glow and fluid animated mesh gradients from image artwork with OKLab color blending for Flutter.