asset_delivery
Ein Flutter-Plugin zur Verwaltung der bedarfsorientierten Aktivlieferung mit Play Asset Delivery, das die Einrichtung von Asset-Packs, die Fortschrittsverfolgung und die persistente Speicherung unterstützt.
mohsen-motlagh/asset_delivery open-source repository details.
{"sdk":"flutter"}^2.0.2{"sdk":"flutter"}^4.0.0Englischer Projektschnappschuss. Aktuelle Inhalte auf GitHub.
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.
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
Add the Play Asset Delivery library to your Gradle file:
implementation "com.google.android.play:asset-delivery:2.2.2"
Run the setup command in the terminal:
dart run asset_delivery:setup_asset_pack "YourAssetPackName"
A folder named after your asset pack will be created, containing:
build.gradle.kts file.manifest folder with an AndroidManifest.xml file.Add your assets in the following path:
ProjectDirectory/Android/YourAssetFolder/src/main/assets/"PUT YOUR ASSETS IN THIS DIRECTORY"
Once published to the Play Store, you can retrieve assets dynamically. To test before publishing, follow the Testing steps below.
For multiple asset packs, repeat these steps for each asset pack.
Download the BundleTool.
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
To get the final APK size:
java -jar bundletool.jar get-size total --apks=<your_temp_dir>/app.apks --dimensions=SDK
Open Xcode and navigate to your Runner project.
Add your assets to the Assets folder.
Configure the asset pack:
Ensure all assets are tagged appropriately.
You can test your iOS app by running it from Xcode on a real device or simulator, as well as using flutter run --release.
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.
Track Download Progress During the download, track the status of the asset pack by calling:
await assetDelivery.getAssetPackStatus();
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').
Please support the plugin by give a thumbs up in pub.dev and github
Contributions are welcome! Feel free to submit issues or pull requests on GitHub.
This plugin is licensed under the MIT License. See the LICENSE file for details.