FLUTTER ECOSYSTEM

bregydoc/pigment

一个简单但有用的 Flutter 颜色操作包

颜料 项目封面
Stars
218
Forks
4
最近推送(UTC)
2025年7月30日
项目状态
未归档
Bregy Malpartida GitHub avatar
GITHUB User

Bregy Malpartida ↗

I love learning, creating things and learning again.

语言DartObjective-C

此仓库发布的插件

使用的依赖

依赖清单 2 项
  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}

原始 README

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

展开 / 收起项目 README

https://github.com/bregydoc/pigment/raw/master/pigment_logo.png

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

https://github.com/bregydoc/pigment/raw/master/pigment_use.png
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)"))),
            ],
          ),
        ));
  }
}