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

插件详情v1.1.1

strcolor

Flutter 包,用于将颜色名称转换为 Flutter 中的 Color。提供了一种便捷的方法,可以通过颜色名称使用颜色,而不是使用 Colors 常量。

近 30 天下载
24
喜欢数
25
Pub 分数
30

安装插件

flutter pub add strcolor

插件介绍

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

strcolor 是一个 Flutter 包,允许开发者使用简单的字符串输入将颜色名称转换为 Color 对象。无需依赖预定义的 Colors 常量,它支持直观的颜色命名(例如 'red'、'blue'、'purple'),使代码更易读。该包支持大量常见颜色名称,简化了用户界面设计中的颜色管理。它轻量且适用于需要动态或人类可读颜色引用的项目。

适合场景

  • 按名称快速分配颜色
  • 动态主题自定义
  • 简化 UI 颜色定义
  • 减少对 Colors 常量的依赖
  • 使用命名颜色提升代码可读性

主要特点

  • 支持常见颜色名称
  • 轻松将字符串转换为颜色
  • 轻量且依赖极少
  • 无需复杂的颜色定义
  • 在 Flutter 小部件中无缝工作

适合对象

  • 初学者Flutter开发者
  • 频繁更改颜色的项目
  • UI 原型设计
  • 使用动态配色方案的应用程序
  • 偏好可读颜色语法的开发者

使用建议

  • 仅限预定义的颜色名称
  • 不支持自定义或十六进制颜色字符串
  • 无效名称没有运行时错误处理
  • 不适合高级色彩操作
  • 需要仔细命名以避免歧义

原始 README

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

strcolor

Dart Pub

Description

Flutter package to convert color names to Color in Flutter.

Offers a handful way to use colors using their names instead of using Colors constants.

It is specialy useful when you need to place color in a component comming dynamically from server.

All Flutter Colors constants supported.

Hexa Colors supported.

Getting Started

In your flutter project add the dependency:

dependencies:
  ...  
  strcolor: ^1.1.1

Usage example

import 'package:strcolor/strcolor.dart';

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(        
        primarySwatch: "purple".color(), // write the color name. When you receive dynamic color name from server this is much more useful.                
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

Dart Pub

strcolor

Author

2020 brworkit.

License

MIT License.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。