flutter_randomcolor 1.0.18 copy "flutter_randomcolor: ^1.0.18" to clipboard
flutter_randomcolor: ^1.0.18 copied to clipboard

A flutter package for generating attractive random colors. it can be used for data visualization, generative and lot more.

RandomColor for Dart & Flutter #

CircleCI Github Code Size Github License Pub version

Generate visually appealing random colors with ease in your Dart and Flutter projects.

Demo

Interactive Demo

Table of Contents #

Features #

  • Generate random colors with fine-tuned control
  • Specify color types, luminosity, and output formats
  • Direct integration with Flutter's Color class
  • Highly customizable with easy-to-use API
  • Consistent results across platforms

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_randomcolor: ^1.0.16
copied to clipboard

Then run:

$ flutter pub get
copied to clipboard

Quick Start #

import 'package:flutter_randomcolor/flutter_randomcolor.dart';

// Generate a random color
var color = RandomColor.getColor(Options());

// Generate a Flutter Color object
Color flutterColor = RandomColor.getColorObject(Options());
copied to clipboard

Usage Guide #

Basic Usage #

Generate a random color with default options:

var color = RandomColor.getColor(Options());
copied to clipboard

Flutter Integration #

Get a Color object for direct use in Flutter widgets:

Color widgetColor = RandomColor.getColorObject(Options(
  colorType: ColorType.blue,
  luminosity: Luminosity.light,
));

// Use in a widget
Container(
  color: widgetColor,
  child: Text('Colored Container'),
)
copied to clipboard

Advanced Options #

Fine-tune your color generation:

var customColor = RandomColor.getColor(Options(
  colorType: [ColorType.red, ColorType.blue],
  luminosity: Luminosity.dark,
  format: Format.rgba,
  alpha: 0.8,
));
copied to clipboard

API Reference #

RandomColor.getColor(Options options) #

Returns a color based on the specified options.

RandomColor.getColorObject(Options options) #

Returns a Flutter Color object based on the specified options.

Options class #

  • colorType: ColorType or List<ColorType>
  • luminosity: Luminosity
  • format: Format
  • alpha: double (0.0 to 1.0)
  • count: int

ColorType

random, monochrome, red, orange, yellow, green, blue, purple, pink

Luminosity

random, dark, light, bright

Format

rgba, rgb, rgbArray, hsla, hex, hsl, hsva, hsvArray, hslArray

Examples #

// Bright green color in hex format
var brightGreen = RandomColor.getColor(Options(
  colorType: ColorType.green,
  luminosity: Luminosity.bright,
  format: Format.hex
));

// Array of 5 pastel colors
var pastelColors = RandomColor.getColor(Options(
  luminosity: Luminosity.light,
  count: 5
));

// Dark red or blue with 50% opacity
var transparentDark = RandomColor.getColor(Options(
  colorType: [ColorType.red, ColorType.blue],
  luminosity: Luminosity.dark,
  format: Format.rgba,
  alpha: 0.5
));


// Flutter Color with seed options to return the same color
var seedColor = RandomColor.getColorObject(Options(
  colorType: ColorType.red,
  luminosity: Luminosity.dark,
  format: Format.hex,
  seed: 1234
));
copied to clipboard

Contributing #

We welcome contributions! Please see our Contributing Guide for more details.

License #

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

Acknowledgements #


Available in Other Languages
30
likes
160
points
1.35k
downloads

Publisher

verified publisherdammak.dev

Weekly Downloads

2024.09.23 - 2025.04.07

A flutter package for generating attractive random colors. it can be used for data visualization, generative and lot more.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_randomcolor