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

插件详情v0.0.1

color_hex

Flutter 包,用于将十六进制字符串转换为 Color(),以及将 Color() 转换为十六进制字符串

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
766
喜欢数
6
Pub 分数
140

安装插件

flutter pub add color_hex

插件介绍

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

color_hex 包是一个轻量级的 Flutter 工具,可实现十六进制颜色字符串与 Flutter 的 Color 对象之间的无缝转换。它通过提供简单的方法来解析十六进制代码(如 '#FF5733')为 Color 实例,并将 Color 对象转换回其十六进制字符串表示形式,从而简化了应用程序中的颜色处理。适用于动态主题、颜色选择器或任何需要从文本输入中操作颜色的场景。

适合场景

  • 将十六进制字符串转换为 Color 对象
  • 从 Color 实例生成十六进制字符串
  • 动态主题自定义
  • 颜色选择器集成
  • 使用十六进制值设置UI元素的样式
  • 保存和加载颜色偏好

主要特点

  • 简单的十六进制到颜色转换
  • 颜色到十六进制字符串序列化
  • 支持十六进制中的 alpha 通道
  • 最小依赖足迹
  • 跨平台兼容性
  • 简洁直观的 API

适合对象

  • 开发人员使用颜色主题
  • 使用颜色选择器的应用
  • 需要十六进制颜色存储的项目
  • UI/UX 设计师实现色彩逻辑
  • Flutter 应用需要一致的颜色处理

使用建议

  • 不验证十六进制格式输入
  • 不支持内置命名颜色
  • 仅限基本颜色字符串操作
  • 需要手动处理无效十六进制的错误
  • 不适合复杂的颜色操作

原始 README

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

color_hex:

A package helps you to convert Hex color to Color() , and convert Color() to hex color

# 👨‍💻 Developed by:

profile

Nasr Al-Rahbi @abom_me

👨🏻‍💻 Find me in :

Twitter Instagram LinkedIn Stack Overflow



🔥 Get Started :

Pubspec changes:

      dependencies:
        color_hex: <last_verison>
How to use it?

you can add it to your text or color as extension like this :

  Color color=Colors.deepPurple;
  String hex="#000000";
  /// here we convert the hex to color and the color to hex 
Text(color.convertToHex.hex,style: TextStyle(color: hex.convertToColor),),

Another way you can convert it using the function :

  Color color=Colors.deepPurple;
  String hex="#000000";
InkWell(
onTap: (){
/// Convert HexColor to Color()
print(hexToColor(hex).toString());
/// Convert Color() to HexColor
print(colorToHex(color).hex);
print(colorToHex(color).color);
},
child:Text("click to convert",style: TextStyle(
/// here we convert the color to hex then we convert the hex to color again
color: color.convertToHex.hex!.convertToColor
),)
)

所属分类

源码仓库

使用此插件的项目

暂无相关数据。