搜尋套件、儲存庫與 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
),)
)

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。