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

套件詳情v1.0.4

pigment

實用且簡單的 Flutter 顏色處理程式。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.8萬
喜歡數
20
Pub 分數
110

安裝套件

flutter pub add pigment

套件介紹

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

Pigment 是一個輕量且直覺的 Flutter 套件,專為簡化應用程式中的色彩處理而設計。它提供清晰的 API,用於建立、操作和轉換色彩,並支援多種色彩模型與格式。適合尋求簡單方式管理色彩邏輯,而不需複雜大型套件的開發者。Pigment 可無縫整合至所有主要平台,包括行動裝置、網頁與桌面,讓其在跨平台專案中極具彈性。

適用情境

  • UI設計中的顏色操作
  • 在顏色格式之間轉換
  • 動態主題生成
  • 自定顏色調色板
  • 簡化應用中的顏色邏輯
  • 響應式顏色調整

主要特色

  • 輕鬆建立和解析顏色
  • 對多種顏色模型(HSL、HSV 等)的支援
  • 內建色彩混合與不透明度處理
  • 跨平台相容性
  • 最小化樣板
  • 可擴展的顏色操作

適合對象

  • Flutter 開發者需要簡單的顏色工具
  • 具有動態或主題色方案的應用程式
  • 設計師和開發人員協作設計UI顏色系統
  • 需要一致色彩管理的項目
  • 原型設計和快速UI開發

使用建議

  • 不適用於進階色彩理論應用
  • 僅限基本顏色操作
  • 無內建色彩選擇器 UI
  • 最適合簡單的顏色處理需求
  • 不取代功能完整的色彩選擇器

原始 README

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

Pigment

pub package

A simple but useful plugin for use colors with Flutter

Features

  • You can use string colors (like #01E19F) direct in flutter
  • Pigment extends to Color dar:ui class, then you can use all methods of Color class
  • Pigment 1.0.1 can parse 'rgb()' (e.g. 'rgb(29, 123, 10)').
  • Added CSS colors with default name, you can access from this with CSSColor.* (e.g. Pigment.fromCSSColor(CSSColor.lightsalmon)) or directly with Pigment.fromString('lightsalmon').

Installation

First, add pigment as a dependency in your pubspec.yaml file.

Use

It's very simple, pigment add a new useful method to Color class, this method is Pigment.fromString(). Also like Color, you can use new Pigment().

Pigment.fromString()
new Pigment()

Example

Here is a small example of the classic and simple pigment use.

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

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Pigment Demo',
      theme: new ThemeData(
        primarySwatch: Colors.red,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: new Text('Pigment App'),
        ),
        body: new Center(
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              new Text('Pigment is cool',
                  style: new TextStyle(color: Pigment.fromString("#FE5567"))),
              new Text('Pigment is cool',
                  style: new TextStyle(color: Pigment.fromString("#01E19F"))),
              new Text('Pigment is cool',
                  style: new TextStyle(color: Pigment.fromString("#4A48D2"))),
              new Text('Pigment is cool',
                  style: new TextStyle(color: Pigment.fromString("rgb(253, 196, 86)"))),
            ],
          ),
        ));
  }
}

所屬分類

原始碼儲存庫

使用此套件的專案