Hi guys, I'm having trouble getting the context in...
# multiplatform
y
Hi guys, I'm having trouble getting the context in android main module. I'm using Koin for dependency injection and I need to pass the context to a function called
saveToGallery
. This function is called from within a coroutine scope in the
downloadImageFromUrl
function.Here is my code:
Copy code
class ThematicaApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        PurchasesFactory.setApplication(this)
        startKoin {
            //androidLogger(if (BuildConfig.DEBUG) Level.ERROR else Level.NONE)
            androidLogger()
            androidContext(this@ThematicaApplication)
            modules(ModuleProvider.getModule())
        }
    }
}

actual fun downloadImageFromUrl(url: String): Flow<Boolean?> = flow {
    val bitmap = withContext(Dispatchers.IO) {
        getBitmapFromURL(url)
    }
    if (bitmap == null) {
        emit(false)
    } else {
        emit(saveToGallery(bitmap, "image.png", context = ?????).first())
    }
}
I'm not sure how to pass the context to the
saveToGallery
function. Can anyone help me with this?