prism_flutter 1.0.0 copy "prism_flutter: ^1.0.0" to clipboard
prism_flutter: ^1.0.0 copied to clipboard

Flutter extensions for the Prism color manipulation library. Seamless conversion between Ray and Flutter Color objects.

Prism Flutter 🌈 #

Flutter extensions for the Prism color manipulation library.

Seamlessly convert between Ray and Flutter Color objects with intuitive extension methods.

Features #

  • 🔄 Seamless conversion: Extensions for both RayColor and ColorRay
  • 🎨 Perfect fidelity: Preserves all ARGB color information
  • Zero overhead: Direct value conversions with no performance cost
  • 🔧 Enhanced manipulation: Access Ray's powerful color operations from Flutter Colors
  • 🎯 Type safe: Comprehensive API with proper error handling

Installation #

Add both packages to your pubspec.yaml:

dependencies:
  prism: ^1.0.0
  prism_flutter: ^1.0.0

Usage #

Ray to Flutter Color #

import 'package:prism_flutter/prism_flutter.dart';

// Convert Ray to Flutter Color
final ray = Ray.fromHex('#FF0000');
final color = ray.toColor();

// Convert with specific opacity
final semiTransparent = ray.toColorWithOpacity(0.5);

Flutter Color to Ray #

import 'package:flutter/material.dart';
import 'package:prism_flutter/prism_flutter.dart';

// Convert Flutter Color to Ray
final color = Colors.red;
final ray = color.toRay();

Enhanced Color Manipulation #

// Chain Ray operations on Flutter Colors
final result = Colors.red
    .toRay()
    .withOpacity(0.8)
    .lerp(Colors.blue.toRay(), 0.3)
    .inverse
    .toColor();

// Use Ray analysis methods
final luminance = Colors.grey.toRay().computeLuminance();
final bestContrast = Colors.grey.toRay().maxContrast(
  Colors.black.toRay(),
  Colors.white.toRay(),
);

Perfect Round-Trip Conversions #

// Ray → Color → Ray maintains perfect fidelity
final originalRay = Ray.fromHex('#7F123456');
final color = originalRay.toColor();
final backToRay = color.toRay();
assert(backToRay == originalRay); // ✅ Always true

// Color → Ray → Color maintains perfect fidelity
const originalColor = Color(0x7F123456);
final ray = originalColor.toRay();
final backToColor = ray.toColor();
assert(backToColor == originalColor); // ✅ Always true

API Reference #

Ray Extensions #

  • toColor() - Convert Ray to Flutter Color
  • toColorWithOpacity(double opacity) - Convert Ray to Flutter Color with specific opacity

Flutter Color Extensions #

  • toRay() - Convert Flutter Color to Ray

All conversions preserve complete ARGB color information with perfect fidelity.

  • prism - The core color manipulation library

License #

MIT License © 2025 Jimmy Forrester-Fellowes - see LICENSE file for details.

3
likes
0
points
113
downloads

Publisher

verified publisherrocketware.co.uk

Weekly Downloads

Flutter extensions for the Prism color manipulation library. Seamless conversion between Ray and Flutter Color objects.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, prism

More

Packages that depend on prism_flutter