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

插件详情v0.1.1+2

gradients

支持 CMYK、HSI、HSL、HSP、HSB、LAB、Oklab、RGB 和 XYZ 颜色空间的 Flutter 线性、径向和扫掠渐变实现。

近 30 天下载
5
喜欢数
26
Pub 分数
60

安装插件

flutter pub add gradients

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

该 gradients 包提供了对 Flutter 的线性、径向和扫掠渐变的增强实现,支持多种色彩空间,包括 CMYK、HSI、HSL、HSP、HSB、LAB、Oklab、RGB 和 XYZ。它使开发者能够使用超越标准 RGB 的高级色彩模型创建丰富且可自定义的渐变效果。适用于需要精确色彩控制的设计类应用,该包在不增加运行时开销的情况下扩展了 Flutter 的原生功能。该库轻量级,并可无缝集成到现有的 Flutter 项目中。

适合场景

  • 使用自定义渐变背景创建视觉丰富的UI
  • 使用非RGB色彩空间设计色彩主题界面
  • 在移动应用中实现渐变动画
  • 使用高级颜色混合功能构建设计工具
  • 通过感知均匀渐变提升可访问性

主要特点

  • 支持9种色彩空间,包括LAB和Oklab
  • 用于线性、径向和扫掠类型的可扩展渐变生成器
  • 与 Flutter 绘画系统的无缝集成
  • 跨多种色彩模型的精确颜色插值
  • 轻量且无依赖

适合对象

  • UI/UX 设计师构建自定义主题
  • 开发创意或艺术类应用的开发者
  • 需要高级颜色操作的应用程序
  • 专注于视觉美学和品牌建设的项目
  • 注重可访问性的应用程序开发

使用建议

  • 需要理解非RGB色彩空间
  • 可能增加初学者的构建复杂性
  • 有限的平台特定优化
  • 最适合对色彩精度要求较高的应用程序
  • 不适用于性能关键的渲染循环

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

gradients

Implementations of Flutter's [LinearGradient], [RadialGradient], and [SweepGradient] with support for the CMYK, HSI, HSL, HSP, HSB, LAB, Oklab, RGB, and XYZ color spaces.

gradients depends on and exposes the flutter_color_models package.

See: flutter_palette, a package for generating color palettes.

Usage

import 'package:gradients/gradients.dart';

The 3 classes in gradients can be used interchangeably with Flutter's [Gradient]s: [LinearGradientPainter], [RadialGradientPainter], and [SweepGradientPainter].

final colors = <Color>[Colors.lime, Colors.pink, Colors.cyan];
final linearGradient = LinearGradientPainter(colors: colors);
final radialGradient = RadialGradientPainter(colors: colors);
final sweepGradient = SweepGradientPainter(colors: colors);

Like [Gradient]s, [GradientPainter]s can be provided to a [BoxDecoration], or the [createShader] method can be used to paint directly to a [Canvas].

final widget = Container(
  decoration: BoxDecoration(
    gradient: LinearGradientPainter(
      colors: <Color>[Colors.lime, Colors.pink, Colors.cyan],
    ),
  ),
);

Color Spaces

By default, [Color]s are interpolated in the RGB color space; A [colorSpace] can be provided to set the color space colors will be interpolated in.

final colors = <Color>[Colors.lime, Colors.pink, Colors.cyan];
final oklabGradient = LinearGradientPainter(
  colorSpace: ColorSpace.oklab,
  colors: colors,
);

Oklab Gradient

Color Models

However, if [ColorModel]s are utilized and no [colorSpace] is provided, the gradient will be interpolated in the color space defined by the starting color within any pair of colors.

final colors = <Color>[
  RgbColor(0, 188, 212),
  HsbColor(35, 100, 100),
  OklabColor(0.9, -0.05, 0.033),
  HspColor(175, 100, 50),
];

// This gradient will be interpolated in the RGB color space,
// then the HSB color space, then the Oklab color space.
final gradient = LinearGradientPainter(colors: colors);

Color Models Example Gradient

If [invert] is set to true, the gradient will be interpolated in the color space defined by the ending color within any pair of colors.

// This gradient will be interpolated in the HSB color space,
// then the Oklab color space, then the HSP color space.
final gradient = LinearGradientPainter(colors: colors, invert: true);

Color Models Inverted Example Gradient

Output

Below is the same set of colors interpolated in each of the supported color spaces.

final colors = <Color>[Colors.lime, Colors.pink, Colors.cyan];
CMYK
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.cmyk);

CMYK Gradient

HSB
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.hsb);

HSB Gradient

HSI
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.hsi);

HSI Gradient

HSL
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.hsl);

HSL Gradient

HSP
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.hsp);

HSP Gradient

LAB
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.lab);

LAB Gradient

Oklab
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.oklab);

Oklab Gradient

RGB
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.rgb);

RGB Gradient

XYZ
final gradient = LinearGradientPainter(
    colors: colors, colorSpace: ColorSpace.xyz);

XYZ Gradient

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。