[英]How to make an asynchronous call from dart the function written in C/C ++?
I carefully read the article https://www.dartlang.org/articles/server/native-extensions and first decided to just test the standard example that is in the sdk-master/samples/sample_extension folder. 我仔细阅读了https://www.dartlang.org/articles/server/native-extensions文章,并首先决定只测试sdk-master / samples / sample_extension文件夹中的标准示例。 The synchronous call works, but when executing the $ dart test_sample_asynchronous_extension.dart command, an "Unhandled exception" error occurs:
同步调用有效,但是在执行$ dart test_sample_asynchronous_extension.dart命令时,发生“未处理的异常”错误:
~/Downloads/sdk-master/samples/sample_extension $ dart test_sample_asynchronous_extension.dart
Unhandled exception:
type 'Future<dynamic>' is not a subtype of type 'Future<List<int>>'
#0 RandomArray.randomArray (file:///home/michael_k/Downloads/sdk-master/samples/sample_extension/sample_asynchronous_extension.dart:32:5)
#1 main (file:///home/michael_k/Downloads/sdk-master/samples/sample_extension/test_sample_asynchronous_extension.dart:17:5)
#2 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:289:19)
#3 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
~/Downloads/sdk-master/samples/sample_extension $
Can anyone know how to solve the problem? 谁知道如何解决这个问题?
I can see the sample files for the example has recently been updated. 我可以看到该示例的示例文件最近已更新。 Try use the latest version of this file: https://github.com/dart-lang/sdk/blob/master/samples/sample_extension/sample_asynchronous_extension.dart
尝试使用此文件的最新版本: https : //github.com/dart-lang/sdk/blob/master/samples/sample_extension/sample_asynchronous_extension.dart
The recent change is the following which seems to fix your problem: 以下是最近的更改,它似乎可以解决您的问题:
Before: 之前:
var completer = new Completer();
After: 后:
var completer = new Completer<List<int>>();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.