Class MethodCall


  • public final class MethodCall
    extends Object
    Command object representing a method call on a MethodChannel.
    • Field Detail

      • method

        public final String method
        The name of the called method.
    • Constructor Detail

      • MethodCall

        public MethodCall​(@NonNull
                          String method,
                          @Nullable
                          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. Possibly, null.
    • Method Detail

      • arguments

        @Nullable
        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​(@NonNull
                              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.