搜尋套件、儲存庫與 APP 分類

flutter_randomcolor 封面
套件詳情v1.0.18

flutter_randomcolor

一個用於產生美觀隨機顏色的 Flutter 套件。可用於資料視覺化、生成式藝術等多種用途。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3840
喜歡數
33
Pub 分數
150

安裝套件

flutter pub add flutter_randomcolor

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

flutter_randomcolor 是一個 Flutter 套件,可產生視覺上吸引人的隨機顏色,非常適合資料視覺化、UI 設計與生成藝術。它透過避免平淡或過於相似的色調,確保色彩多樣性與美學和諧。此套件支援 Android、iOS、Web、macOS、Windows 及 Linux 等多個平台,適用於跨平台應用。透過簡單的 API,開發者可輕鬆將動態顏色產生功能整合至其應用程式中。在為圖表、徽章或使用者產生內容分配不同顏色時尤為實用。

適用情境

  • 數據可視化
  • UI 元素著色
  • 生成藝術
  • 使用者資料圖示
  • 動態主題生成

主要特色

  • 吸引人的顏色生成
  • 避免使用暗淡或相似的顏色
  • 跨平台支援
  • 簡單 API 結合
  • 色彩和諧優化

適合對象

  • 開發人員創建可視化儀表板
  • 需要動態配色方案的設計師
  • 使用者產生內容的應用程式
  • 教育或創意工具
  • 互動式原型

使用建議

  • 可能不適用於嚴格的品牌色彩要求
  • 顏色調色板的自定義選項有限
  • 不適用於以可訪問性為重點的顏色選擇
  • 在隨機性能提升使用者體驗的地方最佳使用
  • 需要手動處理顏色對比

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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

所屬分類

原始碼儲存庫

使用此套件的專案