搜索插件、代码仓与 APP 分类

flutter_media_downloader 封面
插件详情v2.0.0

flutter_media_downloader

此插件帮助用户下载媒体文件,例如 PDF 文件、图像文件等。

AndroidiOS
近 30 天下载
398
喜欢数
52
Pub 分数
140

安装插件

flutter pub add flutter_media_downloader

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 插件,旨在简化下载媒体文件(如图片、PDF 和其他常见文件类型)的过程。它提供了一个简单的 API,用于启动下载、管理下载进度,并在 Android 和 iOS 平台上处理文件存储。该插件与原生下载管理器集成,以确保可靠的后台下载,并支持文件路径管理,便于下载完成后轻松访问。非常适合需要离线媒体访问或内容缓存的应用。

适合场景

  • 下载图像以离线查看
  • 从URL保存PDF
  • 缓存媒体资产以供应用使用
  • 启用用户发起的文件下载
  • 在应用程序中管理大型媒体文件

主要特点

  • 支持多种文件类型(图像、PDF 等)
  • 后台下载功能
  • 下载过程中的进度跟踪
  • 跨平台兼容性(Android 和 iOS)
  • 通过 pub.dev 的简单集成
  • 下载后的文件路径管理

适合对象

  • 需要离线媒体访问的应用
  • 内容分发平台
  • 教育或阅读应用
  • 媒体密集型应用
  • 希望直接从应用中保存文件的用户

使用建议

  • 需要在 Android 和 iOS 上具有适当的权限
  • 可能需要额外处理文件系统访问
  • 下载界面的自定义选项有限
  • 依赖原生下载管理器
  • 不适用于非常大的文件,除非进行分块处理

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flutter_media_downloader

This plugin helps user to download medias for example pdf files, image files etc. A plugin for creating and managing download tasks. Supports iOS and Android.

This plugin is using native methods for push notifications for both platforms (Android & iOS). This is easy to use plugin.

Working Demo

DEMO

Android integration

You just need to add permissions in your manifest file for the push notification. And other permission for read external storage.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <!-- For Android 13+ (API 33 and above) -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
Open downloaded file from notification

To make tapping on notification open the downloaded file on Android, add the following code to AndroidManifest.xml:

<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths" />
</provider>

Notes

  • By default location is provided you can also change it as per your need. Apart from this you can also provide filename if you want to change.
  • Here in this plugin for iOS device when media file is downloaded then it is open and from there you can store wherever you wan to store.
  • Here for push notifications in both the devices native methods are used.
  • For the permission handling you don't need manage it externally all the things are setup you just need to use it.

Usage

Import and full example of using this plugin
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_media_downloader/flutter_media_downloader.dart';

void main() {

  runApp(const MyApp());
  WidgetsFlutterBinding.ensureInitialized();
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  final _flutterMediaDownloaderPlugin = MediaDownload();

  @override
  void initState() {
    super.initState();

  }
  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: ElevatedButton(onPressed: () async {
            _flutterMediaDownloaderPlugin.downloadMedia(context,'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf');
          }, child: const Text('Media Download')),
        ),
      ),
    );
  }
}

Support the Project

If you find this plugin helpful, consider supporting its development:

Your support is greatly appreciated!

Bugs/Requests

Feel free to open an issue if you encounter any problems or think that the plugin is missing some feature.

Email parthsheth100@gmail.com

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。