在Compose Multiplatform中从URL加载图像

5
我目前正在使用Compose多平台项目进行一个项目,并寻找处理从URL加载图像的方法。然而,由于Coil不受支持,我还没有找到解决方案。
我找到了一个手动的Ktor实现,可以转换位图,但它缺乏缓存支持和其他实现细节(例如加载、错误状态)。
有人已经集成了使用库加载图像,或者找到了Compose多平台的其他替代方案吗?

请检查这个链接:https://github.com/Kamel-Media/Kamel - undefined
1个回答

0
Kamel可以从URL加载图像:https://github.com/Kamel-Media/Kamel Gradle依赖项:
kotlin {
    sourceSets {
        commonMain {
            dependencies {
                implementation("media.kamel:kamel-image:x.x.x")
                implementation("io.ktor:ktor-client-okhttp:y.y.y") 
                // ...
            }
        }
    }
}

使用方法:

KamelImage(
    resource = asyncPainterResource(data = "https://example.com/image.jpg"),
    contentDescription = "description"
)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接