搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。