Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
55354aa2
Unverified
Commit
55354aa2
authored
May 11, 2021
by
Ian Hickson
Committed by
GitHub
May 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant OptionalMethodChannel methods (#81930)
parent
58499c29
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
22 deletions
+28
-22
platform_channel.dart
packages/flutter/lib/src/services/platform_channel.dart
+28
-22
No files found.
packages/flutter/lib/src/services/platform_channel.dart
View file @
55354aa2
...
...
@@ -142,6 +142,25 @@ class MethodChannel {
BinaryMessenger
get
binaryMessenger
=>
_binaryMessenger
??
ServicesBinding
.
instance
!.
defaultBinaryMessenger
;
final
BinaryMessenger
?
_binaryMessenger
;
/// Backend implementation of [invokeMethod].
///
/// The `method` and `arguments` arguments are used to create a [MethodCall]
/// object that is passed to the [codec]'s [MethodCodec.encodeMethodCall]
/// method. The resulting message is then sent to the embedding using the
/// [binaryMessenger]'s [BinaryMessenger.send] method.
///
/// If the result is null and `missingOk` is true, this returns null. (This is
/// the behaviour of [OptionalMethodChannel.invokeMethod].)
///
/// If the result is null and `missingOk` is false, this throwsa
/// [MissingPluginException]. (This is the behaviour of
/// [MethodChannel.invokeMethod].)
///
/// Otherwise, the result is decoded using the [codec]'s
/// [MethodCodec.decodeEnvelope] method.
///
/// The `T` type argument is the expected return type. It is treated as
/// nullable.
@optionalTypeArgs
Future
<
T
?>
_invokeMethod
<
T
>(
String
method
,
{
required
bool
missingOk
,
dynamic
arguments
})
async
{
assert
(
method
!=
null
);
...
...
@@ -333,29 +352,29 @@ class MethodChannel {
/// An implementation of [invokeMethod] that can return typed lists.
///
/// Dart generics are reified, meaning that an untyped
List<dynamic>
///
cannot masquerade as a List<T>. Since invokeMethod can only return
///
dynamic
maps, we instead create a new typed list using [List.cast].
/// Dart generics are reified, meaning that an untyped
`List<dynamic>` cannot
///
masquerade as a `List<T>`. Since [invokeMethod] can only return dynamic
/// maps, we instead create a new typed list using [List.cast].
///
/// See also:
///
/// * [invokeMethod], which this call delegates to.
Future
<
List
<
T
>?>
invokeListMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
final
List
<
dynamic
>?
result
=
await
invokeMethod
<
List
<
dynamic
>
?
>(
method
,
arguments
);
final
List
<
dynamic
>?
result
=
await
invokeMethod
<
List
<
dynamic
>>(
method
,
arguments
);
return
result
?.
cast
<
T
>();
}
/// An implementation of [invokeMethod] that can return typed maps.
///
/// Dart generics are reified, meaning that an untyped
Map<dynamic, dynamic>
/// cannot masquerade as a
Map<K, V>. Since invokeMethod
can only return
/// Dart generics are reified, meaning that an untyped
`Map<dynamic, dynamic>`
/// cannot masquerade as a
`Map<K, V>`. Since [invokeMethod]
can only return
/// dynamic maps, we instead create a new typed map using [Map.cast].
///
/// See also:
///
/// * [invokeMethod], which this call delegates to.
Future
<
Map
<
K
,
V
>?>
invokeMapMethod
<
K
,
V
>(
String
method
,
[
dynamic
arguments
])
async
{
final
Map
<
dynamic
,
dynamic
>?
result
=
await
invokeMethod
<
Map
<
dynamic
,
dynamic
>
?
>(
method
,
arguments
);
final
Map
<
dynamic
,
dynamic
>?
result
=
await
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
method
,
arguments
);
return
result
?.
cast
<
K
,
V
>();
}
...
...
@@ -453,26 +472,13 @@ class MethodChannel {
/// instead of throwing an exception.
class
OptionalMethodChannel
extends
MethodChannel
{
/// Creates a [MethodChannel] that ignores missing platform plugins.
const
OptionalMethodChannel
(
String
name
,
[
MethodCodec
codec
=
const
StandardMethodCodec
()])
:
super
(
name
,
codec
);
const
OptionalMethodChannel
(
String
name
,
[
MethodCodec
codec
=
const
StandardMethodCodec
()
,
BinaryMessenger
?
binaryMessenger
])
:
super
(
name
,
codec
,
binaryMessenger
);
@override
Future
<
T
?>
invokeMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
return
super
.
_invokeMethod
<
T
>(
method
,
missingOk:
true
,
arguments:
arguments
);
}
@override
Future
<
List
<
T
>?>
invokeListMethod
<
T
>(
String
method
,
[
dynamic
arguments
])
async
{
final
List
<
dynamic
>?
result
=
await
invokeMethod
<
List
<
dynamic
>>(
method
,
arguments
);
return
result
?.
cast
<
T
>();
}
@override
Future
<
Map
<
K
,
V
>?>
invokeMapMethod
<
K
,
V
>(
String
method
,
[
dynamic
arguments
])
async
{
final
Map
<
dynamic
,
dynamic
>?
result
=
await
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
method
,
arguments
);
return
result
?.
cast
<
K
,
V
>();
}
}
/// A named channel for communicating with platform plugins using event streams.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment