搜索插件、代码仓与 APP 分类

GitHub 代码仓DAMMAK/RandomColorDart

RandomColorDart

一个用于生成吸引人随机颜色的 Dart 包。可用于生成艺术、数据可视化等众多领域。

RandomColorDart 项目封面
星标
14
复刻
6
最近推送(UTC)
2025年2月17日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

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

Then run:

$ flutter pub get

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());

Usage Guide

Basic Usage

Generate a random color with default options:

var color = RandomColor.getColor(Options());
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'),
)
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,
));

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
));

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
Damola Adekoya GitHub avatar
GitHub 作者

Damola Adekoya ↗

Lagos, Nigeria
语言DartShell

分类

此仓库发布的插件

使用的依赖

依赖清单 2 项

  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗