搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。