ambient_backdrop_glow 1.1.3 copy "ambient_backdrop_glow: ^1.1.3" to clipboard
ambient_backdrop_glow: ^1.1.3 copied to clipboard

Dynamic ambient background glow and fluid animated mesh gradients from image artwork with OKLab color blending for Flutter.

ambient_backdrop_glow #

Pub Version Pub Points Live Demo Pub Likes CI License


✨ Why ambient_backdrop_glow? #

Most ambient lighting implementations in Flutter suffer from two major problems:

  1. 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_glow uses the OKLab color space to ensure smooth, constant perceived lightness and chromatic vibrancy.
  2. UI Thread Jank: Extracting color histograms from high-resolution images often drops frames. AmbientColorExtractor automatically 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 CustomPainter with 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:

Buy Me A Coffee GitHub Sponsors Patreon


πŸ“„ License #

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Maintained with ❀️ by Govind Tank.

2
likes
160
points
484
downloads

Documentation

API reference

Publisher

verified publishergovindtank.is-a.dev

Weekly Downloads

Dynamic ambient background glow and fluid animated mesh gradients from image artwork with OKLab color blending for Flutter.

Repository (GitHub)
View/report issues

Topics

#ambient-light #mesh-gradient #backdrop #media-player #custom-painter

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on ambient_backdrop_glow