Visitar URL original
Pigeon : Support for asynchronous methods/Functions by xsahil03x · Pull Request #201 · flutter/packages · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added some spaces in the java code and updated a docstring
  • Loading branch information
gaaclarke committed Sep 29, 2020
commit 666bf38a36adf62ed7d8971c69a8c62d09da4b13
2 changes: 1 addition & 1 deletion packages/pigeon/lib/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Method extends Node {
/// The data-type of the argument.
String argType;

/// Whether the method is asynchronous or not
/// Whether the receiver of this method is expected to return synchronously or not.
bool isAsynchronous;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/pigeon/lib/java_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void _writeHostApi(Indent indent, Api api) {
if (method.isAsynchronous) {
argSignature.add('Result<${method.returnType}> result');
}
indent.writeln('$returnType ${method.name}(${argSignature.join(',')});');
indent.writeln('$returnType ${method.name}(${argSignature.join(', ')});');
}
indent.addln('');
indent.writeln(
Expand Down Expand Up @@ -90,14 +90,14 @@ void _writeHostApi(Indent indent, Api api) {
}
if (method.isAsynchronous) {
methodArgument.add(
'result -> {'
'wrapped.put("${Keys.result}", result.toMap());'
'reply.reply(wrapped);'
'result -> { '
'wrapped.put("${Keys.result}", result.toMap()); '
'reply.reply(wrapped); '
'}',
);
}
final String call =
'api.${method.name}(${methodArgument.join(',')})';
'api.${method.name}(${methodArgument.join(', ')})';
if (method.isAsynchronous) {
indent.writeln('$call;');
} else if (method.returnType == 'void') {
Expand Down