From 6716904385f51e6f3e73d3da91017aff97ce685a Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 28 Apr 2017 07:39:14 -0700 Subject: [PATCH] return the result from calling a service extension (#9636) --- .../lib/src/commands/daemon.dart | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index 7809a6d998..894a1c0ebb 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -441,7 +441,16 @@ class AppDomain extends Domain { }); } - Future callServiceExtension(Map args) async { + /// Returns an error, or the service extension result (a map with two fixed + /// keys, `type` and `method`). The result may have one or more additional keys, + /// depending on the specific service extension end-point. For example: + /// + /// { + /// "value":"android", + /// "type":"_extensionType", + /// "method":"ext.flutter.platformOverride" + /// } + Future> callServiceExtension(Map args) async { final String appId = _getStringArg(args, 'appId', required: true); final String methodName = _getStringArg(args, 'methodName'); final Map params = args['params'] ?? {}; @@ -453,12 +462,12 @@ class AppDomain extends Domain { final Isolate isolate = app.runner.flutterDevices.first.views.first.uiIsolate; final Map result = await isolate.invokeFlutterExtensionRpcRaw(methodName, params: params); if (result == null) - return new OperationResult(1, 'method not available: $methodName'); + throw 'method not available: $methodName'; if (result.containsKey('error')) - return new OperationResult(1, result['error']); - else - return OperationResult.ok; + throw result['error']; + + return result; } Future stop(Map args) async {