Package io.flutter.plugin.common
Class MethodCall
java.lang.Object
io.flutter.plugin.common.MethodCall
Command object representing a method call on a
MethodChannel
.-
Field Summary
-
Constructor Summary
ConstructorDescriptionMethodCall
(String method, Object arguments) Creates aMethodCall
with the specified method name and arguments. -
Method Summary
Modifier and TypeMethodDescription<T> T
<T> T
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, assumingarguments
is aMap
or aJSONObject
.
-
Field Details
-
method
The name of the called method. -
arguments
Arguments for the call.Consider using
arguments()
for cases where a particular run-time type is expected. Consider usingargument(String)
when that run-time type isMap
orJSONObject
.
-
-
Constructor Details
-
MethodCall
Creates aMethodCall
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 Details
-
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
Returns a String-keyed argument of this method call, assumingarguments
is aMap
or aJSONObject
. 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
- ifarguments
can be cast to neitherMap
norJSONObject
.
-
hasArgument
Returns whether this method call involves a mapping for the given argument key, assumingarguments
is aMap
or aJSONObject
. The value associated with the key, as returned byargument(String)
, is not considered, and may benull
.- Parameters:
key
- the String key.- Returns:
true
, ifarguments
is aMap
containing key, or aJSONObject
with a mapping for key.- Throws:
ClassCastException
- ifarguments
can be cast to neitherMap
norJSONObject
.
-