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

套件詳情v1.0.4

icons_helper

當在編譯時無法確定所需的特定圖示時,此功能可在執行時提供對完整圖示庫與 FontAwesomeIcons 的存取。

近 30 天下載
88
喜歡數
27
Pub 分數
40

安裝套件

flutter pub add icons_helper

套件介紹

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

IconsHelper 是一個 Flutter/Dart 套件,可實現對完整圖示庫的執行時存取,包含標準圖示與 FontAwesome 圖示。當所需的圖示是在應用程式執行期間動態決定,而非在編譯時已知時,此工具特別實用。這種彈性讓開發者能建構更具適應性的使用者介面,例如可主題化的圖示選擇器或根據使用者輸入動態呈現圖示的介面。該套件透過提供統一介面來存取廣泛的圖示集,簡化圖示管理,無需逐一匯入每個圖示集。

適用情境

  • 動態圖示選擇
  • 基於主題的圖示渲染
  • 執行時圖示查找
  • 自定圖標選擇組件
  • 可擴展的圖示管理

主要特色

  • 對圖示和 FontAwesomeIcons 的完全存取權限
  • 執行時間圖示解析度
  • 無需靜態匯入
  • 動態使用的簡單API
  • 支援多個圖示庫

適合對象

  • 具有動態 UI 的應用
  • 圖標選擇器介面
  • 主題自定義功能
  • 需要靈活圖示處理的開發者
  • 項目避免在編譯時宣告圖示

使用建議

  • 若未內建,使用 FontAwesomeIcons 需要網路連接
  • 動態解析帶來的微小開銷
  • 不適合效能要求高的圖示渲染
  • 限於預定義的圖示集
  • 可能會稍微增加套件大小

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

icons_helper

This package's use case is to provide access to the full library of Icons and FontAwesomeIcons (currently FontAwesome 9 for the most part, although a few new icons need some addition/changes) at runtime when the specific icons needed are not known at compile time. As such, all Tree Shaking is totally worked around/defeated for Icons and FontAwesomeIcons, so know that before you use the library. But since in our application, for example, the icon names come in from our backend and we don't want to have to re-release each time it specifies a new icon, we are GOOD with that. This is intentional so we can specify a new icon to be displayed just by sending that new text string in our push notification/record. This is a convenience package that provides bracket notiation access to Material Design Icons and Font Awesome Flutter icons (via @brianegan's font_awesome_flutter package). For now, I have just statically generated the Map to map string names to member names. This means any new icons won't be automatically discovered. There's a way to use codegen and mirror in a non-flutter dart app to generate this and then output/maintain them, but just using a google sheet and cut and pasting was faster for something I personally don't need to update often. That sheet is here at https://docs.google.com/spreadsheets/d/1IpWJytpkrJI9_9hwPKY5oXJLRLGjQuG3pUP7eUIqHn4/edit?usp=sharing. I started writing such a utility but gave up because it wasn't worth the time.

Thanks & Contributions

Many thanks to Dennis Bappert (@dennisbappert) and S McDowall (@sjmcdowall) for updates to this and sourcing back their changes publicly and in the true spirit of open source. This includes their fixes.

Using

The methods you may want to consider using include:

getIconUsingPrefix(name: "PREFIX.ICON_NAME") - if PREFIX is "fa" or "fontawesome" the icon_name after the "." will be resolved against the font awesome icons first, if that fails, it'll go to Material Design Icons. If there is no PREFIX.ICON_NAME, it'll fail over to just trying to resolve Material First, then Font Awesome.

getIconGuessFavorFA(name:"ICON_NAME") - if there is an icon named ICON_NAME in FA, return that, otherwise, try Material

getIconGuessFavorMaterial(name:"ICON_NAME") - if there is an icon named ICON_NAME in Material Design, return that, otherwise, try FA

All methods will return null if icon doesn't exist.

Yes, this is a quick and dirty library that could use tons of improvement and does a lot of things poorly or doesn't do things. If you want to change/fix/help, submit a PR and I'll def accept all help that I think improves this lib.

I basically wrote this as a hack/work around to https://github.com/flutter/flutter/issues/16189.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。