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

套件詳情v1.1.0

asset_delivery

一個用於使用 Play Asset Delivery 管理按需資源傳遞的 Flutter 插件,支援資源套裝設定、進度追蹤與持久化儲存。

AndroidiOS
近 30 天下載
415
喜歡數
12
Pub 分數
140

安裝套件

flutter pub add asset_delivery

套件介紹

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

一個 Flutter 插件,利用 Google Play 資產交付實現按需資產傳輸,讓開發者能有效管理大型資產,例如 3D 模型、音訊與影片。它支援資產套件設定、下載過程中的即時進度追蹤,並在應用重啟後維持持久性儲存。專為 Android 與 iOS 所設計,可與 Play 商店的資產傳遞系統無縫整合,從而減少初始應用大小,並透過僅在需要時傳遞資產來改善使用者體驗。

適用情境

  • 按需交付大型遊戲資源
  • 串流傳輸高品質媒體檔案
  • 減少應用初始下載大小
  • 無需完整應用更新即可更新內容
  • 管理動態應用內內容

主要特色

  • 透過 Play 資產傳遞按需交付資源
  • 即時下載進度追蹤
  • 跨會話的持久化資產儲存
  • 支援 Android 與 iOS 平台
  • 與 Google Play 的資源交付系統整合

適合對象

  • 遊戲開發者需要大型資產管理
  • 動態或頻繁更新內容的應用
  • 開發者優化應用大小和效能
  • 使用 Google Play 進行應用分發的團隊
  • 需要高效內容分發工作流程的專案

使用建議

  • 需要 Google Play 用於 Android 資產傳遞
  • 僅限 Android 與 iOS 平台
  • 依賴 Android 上的 Google Play 服務
  • 可能需要在 Google Play Console 中進行額外設定
  • 不適用於在 Google Play 以外分發的應用程式

原始 README

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

Asset Delivery Plugin for Flutter

Introduction

The Asset Delivery Plugin simplifies managing on-demand asset delivery in Flutter applications. It integrates with Play Asset Delivery (Android) and On-Demand Resources (iOS), enabling dynamic asset downloads and seamless user experiences.

Key Features
  • On-Demand Asset Delivery: Download and access assets dynamically at runtime.
  • Customizable Resource Management: Flexible naming patterns and ranges for asset files.
  • Progress Tracking: Real-time download progress updates.
  • Cross-Platform Support: Compatible with both Android and iOS.

Installation

Add the following line to your pubspec.yaml file:

dependencies:
  asset_delivery: 
    git:
      url: https://github.com/mohsen-motlagh/asset_delivery.git
      ref: main

flutter:
  generate: true      

Setup

Android
Minimum SDK Version: 24
  1. Add the Play Asset Delivery library to your Gradle file:

    implementation "com.google.android.play:asset-delivery:2.2.2"
    
  2. Run the setup command in the terminal:

    dart run asset_delivery:setup_asset_pack "YourAssetPackName"
    
  3. A folder named after your asset pack will be created, containing:

    • A build.gradle.kts file.
    • A manifest folder with an AndroidManifest.xml file.
  4. Add your assets in the following path:

    ProjectDirectory/Android/YourAssetFolder/src/main/assets/"PUT YOUR ASSETS IN THIS DIRECTORY"
    
  5. Once published to the Play Store, you can retrieve assets dynamically. To test before publishing, follow the Testing steps below.

  6. For multiple asset packs, repeat these steps for each asset pack.


Android Testing

This method of testing is only available for Android versions below 12. Alternatively, you can publish your app to the Google Play Store for internal testing.

  1. Download the BundleTool.

  2. Build your app bundle and use the following commands:

    • Generate the APKs:

      java -jar bundletool.jar build-apks --bundle=<your_app_project_dir>/build/app/outputs/bundle/release/app-release.aab --output=<your_temp_dir>/app.apks --local-testing
      
    • Install the APKs on your device:

      java -jar bundletool.jar install-apks --apks=<your_temp_dir>/app.apks
      
  3. To get the final APK size:

    java -jar bundletool.jar get-size total --apks=<your_temp_dir>/app.apks --dimensions=SDK
    

iOS
  1. Open Xcode and navigate to your Runner project.

  2. Add your assets to the Assets folder.

  3. Configure the asset pack:

    • Select the asset or folder.
    • In the right panel, find On-Demand Resource Tags under the settings icon.
    • Add your Asset Pack Name (this should match the name used for Android).
  4. Ensure all assets are tagged appropriately.


iOS Testing

You can test your iOS app by running it from Xcode on a real device or simulator, as well as using flutter run --release.

Usage

  1. Download Assets
    On Android devices, download and install assets dynamically using:

    await assetDelivery.fetch("$assetpackName");
    
    - If the assets already exist on the device, the download will be skipped automatically.
    - On iOS, this step is not necessary as assets are accessed directly.
    
    
  2. Track Download Progress During the download, track the status of the asset pack by calling:

    await assetDelivery.getAssetPackStatus();
    
3. Retrieve Asset Path

Get the local path to the downloaded assets using the following code:

  final path = await assetDelivery.getAssetPackPath(
    assetPackName: widget.assetPackName,
    count: widget.assetsCount,
    namingPattern: widget.namingPattern,
    fileExtension: widget.fileExtension,
  );
  Parameters:

  assetPackName: The name of the asset pack.
  count: The number of assets in the pack.
  namingPattern: The naming convention for the assets.
  fileExtension: The file extension of the assets (e.g., 'mp3').
  1. Check for keyword "COMPLETED" from the status to be sure the assets completely downloaded
Example

Example App

Suppor

Please support the plugin by give a thumbs up in pub.dev and github

Contributions

Contributions are welcome! Feel free to submit issues or pull requests on GitHub.

License

This plugin is licensed under the MIT License. See the LICENSE file for details.

所屬分類

依賴

依賴清單 1 項

  • plugin_platform_interface^2.0.2

原始碼儲存庫

使用此套件的專案

暫無相關資料。