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
ef43d000
Commit
ef43d000
authored
Mar 17, 2017
by
Adam Barth
Committed by
GitHub
Mar 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore some missing plugins. (#8852)
Fixes #8850
parent
9f770ec8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
7 deletions
+57
-7
message_codec.dart
packages/flutter/lib/src/services/message_codec.dart
+10
-4
message_codecs.dart
packages/flutter/lib/src/services/message_codecs.dart
+5
-1
platform_channel.dart
packages/flutter/lib/src/services/platform_channel.dart
+19
-0
system_channels.dart
packages/flutter/lib/src/services/system_channels.dart
+6
-2
system_chrome_test.dart
packages/flutter/test/services/system_chrome_test.dart
+17
-0
No files found.
packages/flutter/lib/src/services/message_codec.dart
View file @
ef43d000
...
@@ -166,3 +166,9 @@ class PlatformException implements Exception {
...
@@ -166,3 +166,9 @@ class PlatformException implements Exception {
@override
@override
String
toString
()
=>
'PlatformException(
$code
,
$message
,
$details
)'
;
String
toString
()
=>
'PlatformException(
$code
,
$message
,
$details
)'
;
}
}
/// Thrown to indicate that a platform interaction failed to find the plugin.
class
MissingPluginException
implements
Exception
{
@override
String
toString
()
=>
'MissingPluginException'
;
}
packages/flutter/lib/src/services/message_codecs.dart
View file @
ef43d000
...
@@ -121,6 +121,8 @@ class JSONMethodCodec implements MethodCodec {
...
@@ -121,6 +121,8 @@ class JSONMethodCodec implements MethodCodec {
@override
@override
dynamic
decodeEnvelope
(
ByteData
envelope
)
{
dynamic
decodeEnvelope
(
ByteData
envelope
)
{
if
(
envelope
==
null
)
throw
new
MissingPluginException
();
final
dynamic
decoded
=
const
JSONMessageCodec
().
decodeMessage
(
envelope
);
final
dynamic
decoded
=
const
JSONMessageCodec
().
decodeMessage
(
envelope
);
if
(
decoded
is
!
List
)
if
(
decoded
is
!
List
)
throw
new
FormatException
(
'Expected envelope List, got
$decoded
'
);
throw
new
FormatException
(
'Expected envelope List, got
$decoded
'
);
...
@@ -460,8 +462,10 @@ class StandardMethodCodec implements MethodCodec {
...
@@ -460,8 +462,10 @@ class StandardMethodCodec implements MethodCodec {
@override
@override
dynamic
decodeEnvelope
(
ByteData
envelope
)
{
dynamic
decodeEnvelope
(
ByteData
envelope
)
{
if
(
envelope
==
null
)
throw
new
MissingPluginException
();
// First byte is zero in success case, and non-zero otherwise.
// First byte is zero in success case, and non-zero otherwise.
if
(
envelope
==
null
||
envelope
.
lengthInBytes
==
0
)
if
(
envelope
.
lengthInBytes
==
0
)
throw
const
FormatException
(
'Expected envelope, got nothing'
);
throw
const
FormatException
(
'Expected envelope, got nothing'
);
final
ReadBuffer
buffer
=
new
ReadBuffer
(
envelope
);
final
ReadBuffer
buffer
=
new
ReadBuffer
(
envelope
);
if
(
buffer
.
getUint8
()
==
0
)
if
(
buffer
.
getUint8
()
==
0
)
...
...
packages/flutter/lib/src/services/platform_channel.dart
View file @
ef43d000
...
@@ -261,3 +261,22 @@ class PlatformMethodChannel {
...
@@ -261,3 +261,22 @@ class PlatformMethodChannel {
return
controller
.
stream
;
return
controller
.
stream
;
}
}
}
}
/// A [PlatformMethodChannel] that ignores missing platform plugins.
///
/// When [invokeMethod] fails to find the platform plugin, it returns null
/// instead of throwing an exception.
class
OptionalPlatformMethodChannel
extends
PlatformMethodChannel
{
/// Creates a [PlatformMethodChannel] that ignores missing platform plugins.
const
OptionalPlatformMethodChannel
(
String
name
,
[
MethodCodec
codec
=
const
StandardMethodCodec
()])
:
super
(
name
,
codec
);
@override
Future
<
dynamic
>
invokeMethod
(
String
method
,
[
dynamic
arguments
])
async
{
try
{
return
await
super
.
invokeMethod
(
method
,
arguments
);
}
on
MissingPluginException
{
return
null
;
}
}
}
packages/flutter/lib/src/services/system_channels.dart
View file @
ef43d000
...
@@ -16,13 +16,17 @@ class SystemChannels {
...
@@ -16,13 +16,17 @@ class SystemChannels {
);
);
/// A JSON [PlatformMethodChannel] for invoking miscellaneous platform methods.
/// A JSON [PlatformMethodChannel] for invoking miscellaneous platform methods.
static
const
PlatformMethodChannel
platform
=
const
PlatformMethodChannel
(
///
/// Ignores missing plugins.
static
const
PlatformMethodChannel
platform
=
const
OptionalPlatformMethodChannel
(
'flutter/platform'
,
'flutter/platform'
,
const
JSONMethodCodec
(),
const
JSONMethodCodec
(),
);
);
/// A JSON [PlatformMethodChannel] for handling text input.
/// A JSON [PlatformMethodChannel] for handling text input.
static
const
PlatformMethodChannel
textInput
=
const
PlatformMethodChannel
(
///
/// Ignores missing plugins.
static
const
PlatformMethodChannel
textInput
=
const
OptionalPlatformMethodChannel
(
'flutter/textinput'
,
'flutter/textinput'
,
const
JSONMethodCodec
(),
const
JSONMethodCodec
(),
);
);
...
...
packages/flutter/test/services/system_chrome_test.dart
View file @
ef43d000
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:typed_data'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -54,6 +56,21 @@ void main() {
...
@@ -54,6 +56,21 @@ void main() {
)]));
)]));
});
});
test
(
'setApplicationSwitcherDescription missing plugin'
,
()
async
{
final
List
<
ByteData
>
log
=
<
ByteData
>[];
PlatformMessages
.
setMockBinaryMessageHandler
(
'flutter/platform'
,
(
ByteData
message
)
{
log
.
add
(
message
);
return
null
;
});
await
SystemChrome
.
setApplicationSwitcherDescription
(
const
ApplicationSwitcherDescription
(
label:
'Example label'
,
primaryColor:
0xFF00FF00
)
);
expect
(
log
,
isNotEmpty
);
});
test
(
'setEnabledSystemUIOverlays control test'
,
()
async
{
test
(
'setEnabledSystemUIOverlays control test'
,
()
async
{
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
...
...
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