From c06dce4718ca7a0d7c12d91fb21cf4e624c97f4b Mon Sep 17 00:00:00 2001 From: Mikkel Nygaard Ravn Date: Fri, 26 May 2017 19:39:52 +0200 Subject: [PATCH] Add more docs for MethodChannel.invokeMethod (#10345) --- .../lib/src/services/message_codecs.dart | 4 ---- .../lib/src/services/platform_channel.dart | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/flutter/lib/src/services/message_codecs.dart b/packages/flutter/lib/src/services/message_codecs.dart index c0e34e4037..bb434b3d8e 100644 --- a/packages/flutter/lib/src/services/message_codecs.dart +++ b/packages/flutter/lib/src/services/message_codecs.dart @@ -164,10 +164,6 @@ class JSONMethodCodec implements MethodCodec { /// [MessageCodec] using the Flutter standard binary encoding. /// -/// The standard encoding is guaranteed to be compatible with the corresponding -/// standard codec for FlutterMessageChannels on the host platform. These parts -/// of the Flutter SDK are evolved synchronously. -/// /// Supported messages are acyclic values of these forms: /// /// * null diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart index 3f0ece6fe0..828e2d6e42 100644 --- a/packages/flutter/lib/src/services/platform_channel.dart +++ b/packages/flutter/lib/src/services/platform_channel.dart @@ -17,7 +17,7 @@ import 'platform_messages.dart'; /// Messages are encoded into binary before being sent, and binary messages /// received are decoded into Dart values. The [MessageCodec] used must be /// compatible with the one used by the platform plugin. This can be achieved -/// by creating a [BasicMessageChannel] counterpart of this channel on the +/// by creating a basic message channel counterpart of this channel on the /// platform side. The Dart type of messages sent and received is [T], /// but only the values supported by the specified [MessageCodec] can be used. /// The use of unsupported values should be considered programming errors, and @@ -95,7 +95,7 @@ class BasicMessageChannel { /// Method calls are encoded into binary before being sent, and binary results /// received are decoded into Dart values. The [MethodCodec] used must be /// compatible with the one used by the platform plugin. This can be achieved -/// by creating a `MethodChannel` counterpart of this channel on the +/// by creating a method channel counterpart of this channel on the /// platform side. The Dart type of arguments and results is `dynamic`, /// but only values supported by the specified [MethodCodec] can be used. /// The use of unsupported values should be considered programming errors, and @@ -123,12 +123,26 @@ class MethodChannel { /// Invokes a [method] on this channel with the specified [arguments]. /// + /// The static type of [arguments] is `dynamic`, but only values supported by + /// the [codec] of this channel can be used. The same applies to the returned + /// result. The values supported by the default codec and their platform-specific + /// counterparts are documented with [StandardMessageCodec]. + /// /// Returns a [Future] which completes to one of the following: /// /// * a result (possibly null), on successful invocation; /// * a [PlatformException], if the invocation failed in the platform plugin; /// * a [MissingPluginException], if the method has not been implemented by a /// platform plugin. + /// + /// See also: + /// + /// * [StandardMessageCodec] which defines the payload values supported by + /// [StandardMethodCodec]. + /// * [JSONMessageCodec] which defines the payload values supported by + /// [JSONMethodCodec]. + /// * + /// for how to access method call arguments on Android. Future invokeMethod(String method, [dynamic arguments]) async { assert(method != null); final dynamic result = await BinaryMessages.send(