prism 2.0.0
prism: ^2.0.0 copied to clipboard
An optimized, zero-dependency color manipulation library for Dart & Flutter with multiple color models, accessibility tools, and pre-built palettes.
Prism 🌈 #
An optimized, zero-dependency color manipulation library for Dart & Flutter with multiple color models, accessibility tools, and pre-built palettes.
See prism_flutter which adds Flutter specific extensions.
Resources #
Features #
- 🎨 Multiple color models: RGB (8-bit & 16-bit), HSL, Oklab, and Oklch with seamless conversion
- 🎭 Accessibility schemes: WCAG-compliant color schemes with optimal contrast
- 🎨 Pre-built palettes: Material, CSS, Rainbow, and OpenColor palettes
- 📱 Flutter compatible: Perfect conversion to/from Flutter's Color class
- ⚡ High performance: Zero dependencies with optimized bit operations
- 🌐 Web standards: RGBA/ARGB hex format support
Quick Start #
import 'package:prism/prism.dart';
// Create and convert colors
final red = RayRgb8.fromHex('#FF0000');
final redInOklch = red.toOklch();
final darkRed = redInOklch.withLightness(0.3);
print(darkRed.toRgb8().toHex()); // #521711
Color Models #
Prism supports multiple color models with seamless conversion:
RayRgb8 & RayRgb16 (Red, Green, Blue) #
final red8 = RayRgb8.fromHex('#FF0000');
final red16 = RayRgb16.fromComponents(220, 137, 180);
final transparent = red8.withOpacity(0.5);
print(red8.toHex()); // #FF0000
RayHsl (Hue, Saturation, Lightness) #
final orange = RayHsl.fromComponents(30, 0.8, 0.6);
final shifted = orange.withHue(orange.hue + 60);
print(orange.hueDistance(shifted)); // 60.0°
RayOklab (Perceptually Uniform Color Space) #
final blue = RayOklab.fromComponents(0.452, -0.032, -0.312);
final red = RayOklab.fromComponents(0.628, 0.225, 0.126);
final midpoint = blue.lerp(red, 0.5); // Perceptually uniform
final brighter = blue.withLightness(blue.lightness + 0.2);
RayOklch (Cylindrical Oklab with Intuitive Controls) #
final green = RayOklch.fromComponents(0.7, 0.15, 120.0);
final desaturated = green.withChroma(0.05);
final complementary = green.withHue(green.h + 180);
Easy Conversion #
final red = RayRgb8.fromHex('#FF0000');
final hsl = red.toHsl(); // RGB → HSL
final oklch = red.toOklch(); // RGB → Oklch
final back = hsl.toRgb8(); // HSL → RGB
Performance #
Optimized for performance with efficient bit operations (in RayRgb8), minimal allocations, and zero dependencies.
Note: RayRgb16 uses component arrays instead of bit operations for web compatibility (JavaScript lacks 64-bit integer support). Future platform-specific optimizations planned when Flutter adds 16-bit color support.
Color Palettes #
Prism includes extensive pre-built color palettes with accessibility-focused schemes:
Available Palettes #
Rainbow (Prism's own color palette)

Material Colors

Open Color

CSS Colors

CSS versions of all palettes are also available in the palette_gallery/ directory for web development use.
Usage #
import 'package:prism/palettes/rgb/rainbow.dart';
final primaryBlue = RainbowRgb.blue.source;
final darkBlue = RainbowRgb.blue.shade700;
License #
MIT License © 2025 Jimmy Forrester-Fellowes - see LICENSE file for details.
For an introduction to Prsim see Jimmy's blog post.