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

套件詳情v0.0.3

icon_file

一個用於顯示帶擴展名的文件圖標的小部件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
54
喜歡數
2
Pub 分數
150

安裝套件

flutter pub add icon_file

套件介紹

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

icon_file 是一個 Flutter 套件,提供了一個小組件,根據檔案副檔名顯示檔案圖示。它簡化了在多個平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上顯示各種檔案類型視覺表示的過程。該小組件會自動為常見的副檔名(如 .pdf、.jpg、.txt 等)選擇適當的圖示,從而提升檔案相關應用的使用者介面清晰度。它輕量且容易整合,設定需求極少。

適用情境

  • 在檔案瀏覽器中顯示檔案類型
  • 透過視覺提示增強文件列表
  • 改進雲端儲存應用的使用者介面
  • 顯示上傳介面中的檔案格式
  • 專案管理工具中的視覺反饋

主要特色

  • 根據檔案副檔名自動選擇圖示
  • 支援多個平台
  • 輕量且易於整合
  • 可自定圖標大小和顏色
  • 常見檔案類型的預定義圖示

適合對象

  • 檔案管理應用
  • 文件共享平台
  • 雲端儲存介面
  • 具備檔案處理功能的開發工具
  • 需要視覺檔案類型指示的 UI

使用建議

  • 僅限預定義的檔案副檔名
  • 不支援自定圖示對應
  • 可能需要額外的樣式以保持一致性
  • 依賴外部圖示資源
  • 不適合高度自訂圖示的需求

原始 README

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

📂 icon_file

A Flutter package to automatically display a file icon (SVG) with a dynamic badge based on the file extension (.pdf, .jpg, .zip, etc.).
Perfect for file explorers, downloads, or file previews in apps.

🧩 Features

  • Automatic detection of the file extension
  • Dynamic colored badge based on file type
  • Customizable style (color, text, etc.)
  • Supports over 30 common extensions
  • Ready for responsive layouts (ScreenUtil)
  • Dark mode friendly

📸 Preview

Default Icons Customized Icons
default_icons custom_icons

🚀 Installation

Add this to your pubspec.yaml:

dependencies:
  icon_file: ^1.0.X

Then run:

flutter pub get

🛠️ Basic Usage

import "package:icon_file/icon_file.dart";
FileIcon("document.pdf");

🎨 Example with Custom Styles

FileIcon(
  "custom.pdf",
  color: Colors.deepPurple,
  extensionStyle: TextStyle(
    fontSize: 12,
    fontWeight: FontWeight.bold,
    color: Colors.yellow,
  ),
)

💡 Available Parameters

Parameter Description
fileName (required) File name with extension (document.pdf)
color Custom background color for the badge (optional)
showExtension Whether to show the badge with the extension (default: true)
extensionStyle Text style for the extension badge
assetIcon Custom path to SVG icon (default: assets/file.svg)
size Size of the icon (default: 80)
roundedLabel Whether the badge has rounded corners (default: true)

🔍 Supported Extensions

This package automatically supports the following file types (and can be extended):

pdf, doc, docx, ppt, pptx, xls, xlsx, csv, txt, png, jpg, jpeg, svg, mp3, wav, aac, mp4, avi, mov, js, css, html, json, xml, zip, rar, 7z, tar, gz, dart


🧪 Full Example (UI)

List<String> files = [
  'document.pdf',
  'notes.docx',
  'image.png',
  'video.mp4',
  'music.mp3',
  'slides.pptx',
  'spreadsheet.xlsx',
  'archive.zip',
  'script.js',
  'style.css',
  'readme.txt',
  'logo.svg',
  'data.json',
  'source.dart',
];

List<Widget> icons = files.map((file) => FileIcon(file)).toList();

👥 Contributing

Contributions are welcome!
Feel free to open an issue, submit a pull request, or simply report a bug.


📄 License

This project is licensed under the MIT License.

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。