Package io.flutter.plugin.common

## Class MethodCall

- java.lang.Object
- - io.flutter.plugin.common.MethodCall

-     public final class MethodCall
      extends Object

  Command object representing a method call on a `MethodChannel`.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `Object` | `arguments` | Arguments for the call.
    `String` | `method` | The name of the called method.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MethodCall​(String method, Object arguments)` | Creates a `MethodCall` with the specified method name and arguments.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<T> T` | `argument​(String key)` | Returns a String-keyed argument of this method call, assuming `arguments` is a `Map` or a `JSONObject`.
    `<T> T` | `arguments()` | Returns the arguments of this method call with a static type determined by the call-site.
    `boolean` | `hasArgument​(String key)` | Returns whether this method call involves a mapping for the given argument key, assuming `arguments` is a `Map` or a `JSONObject`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### method

          public final String method

      The name of the called method.

    - #### arguments

          public final Object arguments

      Arguments for the call.

      Consider using `arguments()` for cases where a particular run-time type is expected. Consider using `argument(String)` when that run-time type is `Map` or `JSONObject`.

  - ### Constructor Detail

    - #### MethodCall

          public MethodCall​(String method,
                            Object arguments)

      Creates a `MethodCall` with the specified method name and arguments.
      Parameters:
        `method` - the method name String, not null.
        `arguments` - the arguments, a value supported by the channel's message codec.

  - ### Method Detail

    - #### arguments

          public <T> T arguments()

      Returns the arguments of this method call with a static type determined by the call-site.
      Type Parameters:
        `T` - the intended type of the arguments.
      Returns:
        the arguments with static type T

    - #### argument

          @Nullable
          public <T> T argument​(String key)

      Returns a String-keyed argument of this method call, assuming `arguments` is a `Map` or a `JSONObject`. The static type of the returned result is determined by the call-site.
      Type Parameters:
        `T` - the intended type of the argument.
      Parameters:
        `key` - the String key.
      Returns:
        the argument value at the specified key, with static type T, or `null`, if such an entry is not present.
      Throws:
        `ClassCastException` - if `arguments` can be cast to neither `Map` nor `JSONObject`.

    - #### hasArgument

          public boolean hasArgument​(String key)

      Returns whether this method call involves a mapping for the given argument key, assuming `arguments` is a `Map` or a `JSONObject`. The value associated with the key, as returned by `argument(String)`, is not considered, and may be `null`.
      Parameters:
        `key` - the String key.
      Returns:
        `true`, if `arguments` is a `Map` containing key, or a `JSONObject` with a mapping for key.
      Throws:
        `ClassCastException` - if `arguments` can be cast to neither `Map` nor `JSONObject`.