Assets: Sharing assets with the underlying platform

Sharing assets with the underlying platform

Flutter assets are readily available to platform code via AssetManager on Android and NSBundle on iOS.

Loading Flutter assets in Android

On Android the assets are available via the AssetManager API. The lookup key used in, for instance openFd, is obtained from lookupKeyForAsset on PluginRegistry.Registrar or getLookupKeyForAsset on FlutterView. PluginRegistry.Registrar is available when developing a plugin while FlutterView would be the choice when developing an app including a platform view.

Loading Flutter assets in iOS

On iOS the assets are available via the mainBundle. The lookup key used in, for instance pathForResource:ofType:, is obtained from lookupKeyForAsset or lookupKeyForAsset:fromPackage: on FlutterPluginRegistrar, or lookupKeyForAsset: or lookupKeyForAsset:fromPackage: on FlutterViewController. FlutterPluginRegistrar is available when developing a plugin while FlutterViewController would be the choice when developing an app including a platform view.

To access icons/heart.png from your Objective-C plugin code you would do the following:.

Assets: Sharing assets with the underlying platform — Structure map

Clickable & Draggable!

Assets: Sharing assets with the underlying platform — Related pages: