搜索插件、代码仓与 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)"))),
            ],
          ),
        ));
  }
}

所属分类

源码仓库

使用此插件的项目