搜尋套件、儲存庫與 APP 分類

套件詳情v1.1.1

strcolor

用於將顏色名稱轉換為 Flutter 中 Color 的 Flutter 套件。提供了一種方便的方式,可以透過顏色名稱使用顏色,而非使用 Colors 常數。

近 30 天下載
24
喜歡數
25
Pub 分數
30

安裝套件

flutter pub add strcolor

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

strcolor 是一個 Flutter 套件,讓開發者能使用簡單的字串輸入將顏色名稱轉換為 Color 物件。不需要依賴預定義的 Colors 常數,它支援直覺性的顏色命名(例如 'red'、'blue'、'purple'),讓程式碼更易讀。此套件支援廣泛的常見顏色名稱,簡化 UI 設計中的色彩管理。輕量級,適合偏好動態或人類可讀色彩參考的專案。

適用情境

  • 按名稱快速指派顏色
  • 動態主題自訂
  • 簡化 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。