我在 Flutter 中使用 PlatformChannel 和 MethodChannel。做一些基本的操作......为颤振做一个opencv移植......但我不知道如何解决这个问题!
调用返回基本类型对象的简单方法没有问题,如下所示:
安卓:
@Override
public void onMethodCall(final MethodCall call, final Result result) {
switch (call.method) {
case "getVersionString":
result.success(org.opencv.core.Core.getVersionString());
break;
default:
result.notImplemented();
}
}
镖:
Future<String> get versionString async {
return await _channel.invokeMethod('getVersionString') as String;
}
但是如果我有一些自定义对象呢?类似的东西:
安卓:
@Override
public void onMethodCall(final MethodCall call, final Result result) {
switch (call.method) {
case "getVersionString":
result.success(org.opencv.core.Core.getVersionString());
break;
case "Scalar":
result.success(org.opencv.core.Core.Scalar());
break;
default:
result.notImplemented();
}
}
}
镖:
class Scalar {
static const MethodChannel _channel = MethodChannel('flutter_opencv');
// WHAT TO DO HERE??????
}
如何实现标量飞镖类?我需要从原始资源开始重写课程还是什么?
感谢您的关注。