问题描述
我正在构建一个 Flutter 应用程序,对于我使用的其中一个 API,它不支持 Flutter,只有 Android 和 iOS。我对此的解决方案是使用平台通道,但我如何将图像作为参数传递?
进一步解释一下,我正在从图库中选择一个带有 ImagePicker().getImage
的 dart 文件的图像,并且我想将所选图像发送到 Kotlin 文件中的方法,该方法将对图像执行某些操作并返回一个字符串。
在查看文档后,我能够创建这样的频道:
static const platform = const MethodChannel('app.dev/channel');
final string result = await platform.invokeMethod('returnStringfromImage');
在 Kotlin 文件中:
private val CHANNEL = "app.dev/channel"
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger,CHANNEL).setMethodCallHandler {
// Note: this method is invoked on the main thread.
call,result ->
if (call.method == "returnStringfromImage") {
val return = returnStringfromImage(call.arguments)
}
else {
result.notImplemented()
}
}
}
我将如何发送图像,并将其作为 returnStringfromImage() 方法的参数传递?谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)