prism_flutter 1.0.1 copy "prism_flutter: ^1.0.1" to clipboard
prism_flutter: ^1.0.1 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.

Resources #

Features #

  • πŸ”„ Seamless conversion: Extensions for both Ray β†’ Color and Color β†’ Ray
  • 🎨 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
125
points
578
downloads

Documentation

API reference

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

MIT (license)

Dependencies

flutter, prism

More

Packages that depend on prism_flutter