1

I am trying to find a way to pass parameters from my flutter/dart app to a plugin I am writing in java. My goal is to let the dart code pass a standard Icon as parameters to the plugin and the latter showing it in an ImageView. My attempts are to pass the IconData containing the font and the unicode for the icon as well as the hex color of that icon. On the the plugin side, there will be a retrieval of that icon using the IconData and applying the color via from the hex color.

I can pass the arguments to the plugin like any other String argument but I didn't find a way to do the java part. I have tried creating Bitmaps and then changing their colors but that didn't work at all.

I am asking if there is a known way to passing icons from dart to flutter especially when they are based on external fonts?

Kaki Master Of Time
  • 1,428
  • 1
  • 21
  • 39
  • Something similar has been already asked eg. here: https://stackoverflow.com/questions/15210548/how-to-use-icons-and-symbols-from-font-awesome-on-native-android-application – nvi9 Feb 25 '20 at 21:08
  • @nvi9 yeah I saw those answers, it I still not the one I am looking for – Kaki Master Of Time Feb 25 '20 at 22:23

1 Answers1

1

You can pass the image name as a string to your android plugin and use AssetManager to get the path to as described in flutter documentation.

for example:

    val assetManager: AssetManager = registrar.context().assets
    val key: String = registrar.lookupKeyForAsset("image")
    val fd = assetManager.openFd(key)
    val image = BitmapFactory.decodeStream(fd.createInputStream())
etzuk
  • 436
  • 4
  • 9