Search packages, repositories and app categories

rainbow_color cover
Package detailsv2.0.1

rainbow_color

Simplified multi-color interpolation. Map a numerical domain to a smooth-transitioning color range.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
3K
Likes
35
Pub points
150

Install package

flutter pub add rainbow_color

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

RainbowColor is a Flutter/Dart package that simplifies multi-color interpolation by mapping a numerical range to a smooth, visually appealing color gradient. It enables developers to generate seamless transitions between multiple colors based on input values, ideal for data visualization, progress indicators, and dynamic UI elements. The package supports all major platforms and integrates easily with existing Flutter projects. With minimal setup, it provides consistent, high-quality color transitions without requiring complex custom logic.

Use cases

  • Data visualization
  • Progress indicators
  • Dynamic UI themes
  • Gradient animations
  • Interactive charts

Key features

  • Smooth multi-color interpolation
  • Simple API
  • Cross-platform support
  • Customizable color ranges
  • Automatic gradient generation

Suitable for

  • UI designers
  • Data visualization apps
  • Animated interfaces
  • Educational tools
  • Gamified applications

Considerations

  • Limited to linear color transitions
  • Requires understanding of color domains
  • Not optimized for real-time high-frequency updates
  • No built-in color palette presets
  • Dependent on input value range precision

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

rainbow_color

Pub Travis

RainbowColor simplifies interpolation a numerical domain onto a multi-color range. RainbowColor accepts a numerical domain (i.e. a start and end number) and a spectrum of two or more colors, and offers the list access operator ([]) for interpolation.

This package also provides RainbowColorTween, a multi-color variant of the standard ColorTween, eliminating the need to build more complex TweenSequence for equal-weight transitions.

Usage

To interpolate a color among the spectrum, use the list access operator, e.g.

import 'package:rainbow_color/rainbow_color.dart';

var rb = Rainbow(spectrum: [Color(0xFFFF0000), Color(0xFFFFFFFF), Color(0xff00ff00)],
                 rangeStart: -10,
                 rangeEnd: 10);
Color warmColor = rb[-9.32];
Color coldColor = rb[8.44];

Or use RainbowColorTween in place of ColorTween to interpolate among multiple colors instead of two.

@override
  void initState() {
    super.initState();
    _controller = AnimationController(duration: widget.duration, vsync: this);
    _clAnim = RainbowColorTween([Color(0x33FFAAAA),
                                 Color(0x33000000),
                                 Color(0x00000000)]).animate(_controller)
                                                    ..addListener(() { 
                                                         setState(() {}); 
                                                    });
}

See Also

This is a Flutter-oriented version of the vanilla Dart package rainbow_vis.

Categories

Dependencies

Dependency list 1 items

  • rainbow_vis^2.0.0

Source repository

Projects using this package