mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 23:51:55 +08:00
[pigeon] Fixed void void async methods (#316)
* [pigeon] Fixed void void async methods * format
This commit is contained in:
@ -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(', ')});');
|
||||
}
|
||||
@ -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); '
|
||||
'}',
|
||||
);
|
||||
|
@ -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) {',
|
||||
|
@ -12,6 +12,8 @@ class Value {
|
||||
abstract class Api2Host {
|
||||
@async
|
||||
Value calculate(Value value);
|
||||
@async
|
||||
void voidVoid();
|
||||
}
|
||||
|
||||
@FlutterApi()
|
||||
|
Reference in New Issue
Block a user