Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/pigeon/lib/java_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ void _writeHostApi(Indent indent, Api api) {
argSignature.add('${method.argType} arg');
}
if (method.isAsynchronous) {
argSignature.add('Result<${method.returnType}> result');
final String returnType =
method.returnType == 'void' ? 'Void' : method.returnType;
argSignature.add('Result<$returnType> result');
}
indent.writeln('$returnType ${method.name}(${argSignature.join(', ')});');
}
Expand Down Expand Up @@ -94,9 +96,11 @@ void _writeHostApi(Indent indent, Api api) {
methodArgument.add('input');
}
if (method.isAsynchronous) {
final String resultValue =
method.returnType == 'void' ? 'null' : 'result.toMap()';
methodArgument.add(
'result -> { '
'wrapped.put("${Keys.result}", result.toMap()); '
'wrapped.put("${Keys.result}", $resultValue); '
'reply.reply(wrapped); '
'}',
);
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/objc_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void _writeHostApiSource(Indent indent, ObjcOptions options, Api api) {
}
if (func.isAsynchronous) {
if (func.returnType == 'void') {
const String callback = 'callback(error));';
const String callback = 'callback(error);';
if (func.argType == 'void') {
indent.writeScoped(
'[api ${func.name}:^(FlutterError *_Nullable error) {',
Expand Down
2 changes: 2 additions & 0 deletions packages/pigeon/pigeons/async_handlers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Value {
abstract class Api2Host {
@async
Value calculate(Value value);
@async
void voidVoid();
}

@FlutterApi()
Expand Down