2

I am building a plugin and need to make use of images (like Image.asset or Image.file) and need to pass them to my native plugin. However, I could not find a decent way to pass these. Does anyone know how to achieve that and how these objects are used natively in general?

ktm125
  • 442
  • 5
  • 21

1 Answers1

2

You can pass the asset path and read it via Flutter:

  1. Pass the asset path through MethodChannel
  2. Look for the asset using it's path:
AssetManager assetManager = registrar.context().getAssets();
String key = registrar.lookupKeyForAsset("icons/heart.png");
AssetFileDescriptor fd = assetManager.openFd(key);

Flutter docs

Mahdi-Malv
  • 16,677
  • 10
  • 70
  • 117