Skip to content

Commit

Permalink
Add nullability annotations to MethodChannel/MethodCall. (flutter#6393)
Browse files Browse the repository at this point in the history
This works towards resolving flutter/flutter#19888.
  • Loading branch information
nichtverstehen authored and matthew-carroll committed Oct 2, 2018
1 parent 71ba20a commit 68a42e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.flutter.plugin.common;

import android.support.annotation.Nullable;
import java.util.Map;
import org.json.JSONObject;

Expand Down Expand Up @@ -61,6 +62,7 @@ public <T> T arguments() {
* {@link JSONObject}.
*/
@SuppressWarnings("unchecked")
@Nullable
public <T> T argument(String key) {
if (arguments == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.flutter.plugin.common;

import android.support.annotation.Nullable;
import android.util.Log;
import io.flutter.plugin.common.BinaryMessenger.BinaryMessageHandler;
import io.flutter.plugin.common.BinaryMessenger.BinaryReply;
Expand Down Expand Up @@ -65,7 +66,7 @@ public MethodChannel(BinaryMessenger messenger, String name, MethodCodec codec)
* @param method the name String of the method.
* @param arguments the arguments for the invocation, possibly null.
*/
public void invokeMethod(String method, Object arguments) {
public void invokeMethod(String method, @Nullable Object arguments) {
invokeMethod(method, arguments, null);
}

Expand All @@ -78,7 +79,7 @@ public void invokeMethod(String method, Object arguments) {
* @param arguments the arguments for the invocation, possibly null.
* @param callback a {@link Result} callback for the invocation result, or null.
*/
public void invokeMethod(String method, Object arguments, Result callback) {
public void invokeMethod(String method, @Nullable Object arguments, Result callback) {
messenger.send(name, codec.encodeMethodCall(new MethodCall(method, arguments)),
callback == null ? null : new IncomingResultHandler(callback));
}
Expand All @@ -97,7 +98,7 @@ public void invokeMethod(String method, Object arguments, Result callback) {
*
* @param handler a {@link MethodCallHandler}, or null to deregister.
*/
public void setMethodCallHandler(final MethodCallHandler handler) {
public void setMethodCallHandler(final @Nullable MethodCallHandler handler) {
messenger.setMessageHandler(name,
handler == null ? null : new IncomingMethodCallHandler(handler));
}
Expand Down Expand Up @@ -143,7 +144,7 @@ public interface Result {
*
* @param result The result, possibly null.
*/
void success(Object result);
void success(@Nullable Object result);

/**
* Handles an error result.
Expand All @@ -152,7 +153,7 @@ public interface Result {
* @param errorMessage A human-readable error message String, possibly null.
* @param errorDetails Error details, possibly null
*/
void error(String errorCode, String errorMessage, Object errorDetails);
void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails);

/**
* Handles a call to an unimplemented method.
Expand Down

0 comments on commit 68a42e3

Please sign in to comment.