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
3c77c432
Unverified
Commit
3c77c432
authored
Feb 17, 2021
by
Ren You
Committed by
GitHub
Feb 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Remove some `dynamic's. (#75820)" (#76232)
This reverts commit
2d9a01a8
.
parent
3cbe0ff1
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
88 deletions
+66
-88
message_codec.dart
packages/flutter/lib/src/services/message_codec.dart
+4
-10
message_codecs.dart
packages/flutter/lib/src/services/message_codecs.dart
+41
-57
platform_channel.dart
packages/flutter/lib/src/services/platform_channel.dart
+3
-3
restoration.dart
packages/flutter/lib/src/services/restoration.dart
+15
-15
message_codecs_testing.dart
packages/flutter/test/services/message_codecs_testing.dart
+2
-2
plugin_registry_test.dart
packages/flutter_web_plugins/test/plugin_registry_test.dart
+1
-1
No files found.
packages/flutter/lib/src/services/message_codec.dart
View file @
3c77c432
...
@@ -29,7 +29,7 @@ abstract class MessageCodec<T> {
...
@@ -29,7 +29,7 @@ abstract class MessageCodec<T> {
/// Decodes the specified [message] from binary.
/// Decodes the specified [message] from binary.
///
///
/// Returns null if the message is null.
/// Returns null if the message is null.
T
?
decodeMessage
(
ByteData
?
message
);
T
decodeMessage
(
ByteData
?
message
);
}
}
/// An command object representing the invocation of a named method.
/// An command object representing the invocation of a named method.
...
@@ -73,22 +73,16 @@ abstract class MethodCodec {
...
@@ -73,22 +73,16 @@ abstract class MethodCodec {
///
///
/// Throws [PlatformException], if [envelope] represents an error, otherwise
/// Throws [PlatformException], if [envelope] represents an error, otherwise
/// returns the enveloped result.
/// returns the enveloped result.
///
/// The type returned from [decodeEnvelope] is `dynamic` (not `Object?`),
/// which means *no type checking is performed on its return value*. It is
/// strongly recommended that the return value be immediately cast to a known
/// type to prevent runtime errors due to typos that the type checker could
/// otherwise catch.
dynamic
decodeEnvelope
(
ByteData
envelope
);
dynamic
decodeEnvelope
(
ByteData
envelope
);
/// Encodes a successful [result] into a binary envelope.
/// Encodes a successful [result] into a binary envelope.
ByteData
encodeSuccessEnvelope
(
Object
?
result
);
ByteData
encodeSuccessEnvelope
(
dynamic
result
);
/// Encodes an error result into a binary envelope.
/// Encodes an error result into a binary envelope.
///
///
/// The specified error [code], human-readable error [message] and error
/// The specified error [code], human-readable error [message] and error
/// [details] correspond to the fields of [PlatformException].
/// [details] correspond to the fields of [PlatformException].
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
Object
?
details
});
ByteData
encodeErrorEnvelope
({
required
String
code
,
String
?
message
,
dynamic
details
});
}
}
...
@@ -123,7 +117,7 @@ class PlatformException implements Exception {
...
@@ -123,7 +117,7 @@ class PlatformException implements Exception {
final
String
?
message
;
final
String
?
message
;
/// Error details, possibly null.
/// Error details, possibly null.
final
Object
?
details
;
final
dynamic
details
;
/// Native stacktrace for the error, possibly null.
/// Native stacktrace for the error, possibly null.
/// This is strictly for native platform stacktrace.
/// This is strictly for native platform stacktrace.
...
...
packages/flutter/lib/src/services/message_codecs.dart
View file @
3c77c432
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/services/platform_channel.dart
View file @
3c77c432
...
@@ -52,7 +52,7 @@ class BasicMessageChannel<T> {
...
@@ -52,7 +52,7 @@ class BasicMessageChannel<T> {
///
///
/// Returns a [Future] which completes to the received response, which may
/// Returns a [Future] which completes to the received response, which may
/// be null.
/// be null.
Future
<
T
?
>
send
(
T
message
)
async
{
Future
<
T
>
send
(
T
message
)
async
{
return
codec
.
decodeMessage
(
await
binaryMessenger
.
send
(
name
,
codec
.
encodeMessage
(
message
)));
return
codec
.
decodeMessage
(
await
binaryMessenger
.
send
(
name
,
codec
.
encodeMessage
(
message
)));
}
}
...
@@ -65,7 +65,7 @@ class BasicMessageChannel<T> {
...
@@ -65,7 +65,7 @@ class BasicMessageChannel<T> {
///
///
/// The handler's return value is sent back to the platform plugins as a
/// The handler's return value is sent back to the platform plugins as a
/// message reply. It may be null.
/// message reply. It may be null.
void
setMessageHandler
(
Future
<
T
>
Function
(
T
?
message
)?
handler
)
{
void
setMessageHandler
(
Future
<
T
>
Function
(
T
message
)?
handler
)
{
if
(
handler
==
null
)
{
if
(
handler
==
null
)
{
binaryMessenger
.
setMessageHandler
(
name
,
null
);
binaryMessenger
.
setMessageHandler
(
name
,
null
);
}
else
{
}
else
{
...
@@ -86,7 +86,7 @@ class BasicMessageChannel<T> {
...
@@ -86,7 +86,7 @@ class BasicMessageChannel<T> {
///
///
/// This is intended for testing. Messages intercepted in this manner are not
/// This is intended for testing. Messages intercepted in this manner are not
/// sent to platform plugins.
/// sent to platform plugins.
void
setMockMessageHandler
(
Future
<
T
>
Function
(
T
?
message
)?
handler
)
{
void
setMockMessageHandler
(
Future
<
T
>
Function
(
T
message
)?
handler
)
{
if
(
handler
==
null
)
{
if
(
handler
==
null
)
{
binaryMessenger
.
setMockMessageHandler
(
name
,
null
);
binaryMessenger
.
setMockMessageHandler
(
name
,
null
);
}
else
{
}
else
{
...
...
packages/flutter/lib/src/services/restoration.dart
View file @
3c77c432
...
@@ -226,7 +226,7 @@ class RestorationManager extends ChangeNotifier {
...
@@ -226,7 +226,7 @@ class RestorationManager extends ChangeNotifier {
bool
_isReplacing
=
false
;
bool
_isReplacing
=
false
;
Future
<
void
>
_getRootBucketFromEngine
()
async
{
Future
<
void
>
_getRootBucketFromEngine
()
async
{
final
Map
<
Object
?,
Object
?>?
config
=
await
SystemChannels
.
restoration
.
invokeMethod
<
Map
<
Object
?,
Object
?
>>(
'get'
);
final
Map
<
dynamic
,
dynamic
>?
config
=
await
SystemChannels
.
restoration
.
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
'get'
);
if
(
_pendingRootBucket
==
null
)
{
if
(
_pendingRootBucket
==
null
)
{
// The restoration data was obtained via other means (e.g. by calling
// The restoration data was obtained via other means (e.g. by calling
// [handleRestorationDataUpdate] while the request to the engine was
// [handleRestorationDataUpdate] while the request to the engine was
...
@@ -237,9 +237,9 @@ class RestorationManager extends ChangeNotifier {
...
@@ -237,9 +237,9 @@ class RestorationManager extends ChangeNotifier {
_parseAndHandleRestorationUpdateFromEngine
(
config
);
_parseAndHandleRestorationUpdateFromEngine
(
config
);
}
}
void
_parseAndHandleRestorationUpdateFromEngine
(
Map
<
Object
?,
Object
?
>?
update
)
{
void
_parseAndHandleRestorationUpdateFromEngine
(
Map
<
dynamic
,
dynamic
>?
update
)
{
handleRestorationUpdateFromEngine
(
handleRestorationUpdateFromEngine
(
enabled:
update
!=
null
&&
update
[
'enabled'
]
!
as
bool
,
enabled:
update
!=
null
&&
update
[
'enabled'
]
as
bool
,
data:
update
==
null
?
null
:
update
[
'data'
]
as
Uint8List
?,
data:
update
==
null
?
null
:
update
[
'data'
]
as
Uint8List
?,
);
);
}
}
...
@@ -305,25 +305,25 @@ class RestorationManager extends ChangeNotifier {
...
@@ -305,25 +305,25 @@ class RestorationManager extends ChangeNotifier {
);
);
}
}
Future
<
Object
?
>
_methodHandler
(
MethodCall
call
)
async
{
Future
<
dynamic
>
_methodHandler
(
MethodCall
call
)
async
{
switch
(
call
.
method
)
{
switch
(
call
.
method
)
{
case
'push'
:
case
'push'
:
_parseAndHandleRestorationUpdateFromEngine
(
call
.
arguments
as
Map
<
Object
?,
Object
?
>);
_parseAndHandleRestorationUpdateFromEngine
(
call
.
arguments
as
Map
<
dynamic
,
dynamic
>);
break
;
break
;
default
:
default
:
throw
UnimplementedError
(
"
${call.method}
was invoked but isn't implemented by
$runtimeType
"
);
throw
UnimplementedError
(
"
${call.method}
was invoked but isn't implemented by
$runtimeType
"
);
}
}
}
}
Map
<
Object
?,
Object
?
>?
_decodeRestorationData
(
Uint8List
?
data
)
{
Map
<
dynamic
,
dynamic
>?
_decodeRestorationData
(
Uint8List
?
data
)
{
if
(
data
==
null
)
{
if
(
data
==
null
)
{
return
null
;
return
null
;
}
}
final
ByteData
encoded
=
data
.
buffer
.
asByteData
(
data
.
offsetInBytes
,
data
.
lengthInBytes
);
final
ByteData
encoded
=
data
.
buffer
.
asByteData
(
data
.
offsetInBytes
,
data
.
lengthInBytes
);
return
const
StandardMessageCodec
().
decodeMessage
(
encoded
)
as
Map
<
Object
?,
Object
?>?
;
return
const
StandardMessageCodec
().
decodeMessage
(
encoded
)
as
Map
<
dynamic
,
dynamic
>
;
}
}
Uint8List
_encodeRestorationData
(
Map
<
Object
?,
Object
?
>
data
)
{
Uint8List
_encodeRestorationData
(
Map
<
dynamic
,
dynamic
>
data
)
{
final
ByteData
encoded
=
const
StandardMessageCodec
().
encodeMessage
(
data
)!;
final
ByteData
encoded
=
const
StandardMessageCodec
().
encodeMessage
(
data
)!;
return
encoded
.
buffer
.
asUint8List
(
encoded
.
offsetInBytes
,
encoded
.
lengthInBytes
);
return
encoded
.
buffer
.
asUint8List
(
encoded
.
offsetInBytes
,
encoded
.
lengthInBytes
);
}
}
...
@@ -505,7 +505,7 @@ class RestorationBucket {
...
@@ -505,7 +505,7 @@ class RestorationBucket {
required
Object
?
debugOwner
,
required
Object
?
debugOwner
,
})
:
assert
(
restorationId
!=
null
),
})
:
assert
(
restorationId
!=
null
),
_restorationId
=
restorationId
,
_restorationId
=
restorationId
,
_rawData
=
<
String
,
Object
?
>{}
{
_rawData
=
<
String
,
dynamic
>{}
{
assert
(()
{
assert
(()
{
_debugOwner
=
debugOwner
;
_debugOwner
=
debugOwner
;
return
true
;
return
true
;
...
@@ -537,10 +537,10 @@ class RestorationBucket {
...
@@ -537,10 +537,10 @@ class RestorationBucket {
/// The `manager` argument must not be null.
/// The `manager` argument must not be null.
RestorationBucket
.
root
({
RestorationBucket
.
root
({
required
RestorationManager
manager
,
required
RestorationManager
manager
,
required
Map
<
Object
?,
Object
?
>?
rawData
,
required
Map
<
dynamic
,
dynamic
>?
rawData
,
})
:
assert
(
manager
!=
null
),
})
:
assert
(
manager
!=
null
),
_manager
=
manager
,
_manager
=
manager
,
_rawData
=
rawData
??
<
Object
?,
Object
?
>{},
_rawData
=
rawData
??
<
dynamic
,
dynamic
>{},
_restorationId
=
'root'
{
_restorationId
=
'root'
{
assert
(()
{
assert
(()
{
_debugOwner
=
manager
;
_debugOwner
=
manager
;
...
@@ -567,7 +567,7 @@ class RestorationBucket {
...
@@ -567,7 +567,7 @@ class RestorationBucket {
assert
(
parent
.
_rawChildren
[
restorationId
]
!=
null
),
assert
(
parent
.
_rawChildren
[
restorationId
]
!=
null
),
_manager
=
parent
.
_manager
,
_manager
=
parent
.
_manager
,
_parent
=
parent
,
_parent
=
parent
,
_rawData
=
parent
.
_rawChildren
[
restorationId
]
!
as
Map
<
Object
?,
Object
?
>,
_rawData
=
parent
.
_rawChildren
[
restorationId
]
as
Map
<
dynamic
,
dynamic
>,
_restorationId
=
restorationId
{
_restorationId
=
restorationId
{
assert
(()
{
assert
(()
{
_debugOwner
=
debugOwner
;
_debugOwner
=
debugOwner
;
...
@@ -578,7 +578,7 @@ class RestorationBucket {
...
@@ -578,7 +578,7 @@ class RestorationBucket {
static
const
String
_childrenMapKey
=
'c'
;
static
const
String
_childrenMapKey
=
'c'
;
static
const
String
_valuesMapKey
=
'v'
;
static
const
String
_valuesMapKey
=
'v'
;
final
Map
<
Object
?,
Object
?
>
_rawData
;
final
Map
<
dynamic
,
dynamic
>
_rawData
;
/// The owner of the bucket that was provided when the bucket was claimed via
/// The owner of the bucket that was provided when the bucket was claimed via
/// [claimChild].
/// [claimChild].
...
@@ -616,9 +616,9 @@ class RestorationBucket {
...
@@ -616,9 +616,9 @@ class RestorationBucket {
String
_restorationId
;
String
_restorationId
;
// Maps a restoration ID to the raw map representation of a child bucket.
// Maps a restoration ID to the raw map representation of a child bucket.
Map
<
Object
?,
Object
?>
get
_rawChildren
=>
_rawData
.
putIfAbsent
(
_childrenMapKey
,
()
=>
<
Object
?,
Object
?>{})!
as
Map
<
Object
?,
Object
?
>;
Map
<
dynamic
,
dynamic
>
get
_rawChildren
=>
_rawData
.
putIfAbsent
(
_childrenMapKey
,
()
=>
<
dynamic
,
dynamic
>{})
as
Map
<
dynamic
,
dynamic
>;
// Maps a restoration ID to a value that is stored in this bucket.
// Maps a restoration ID to a value that is stored in this bucket.
Map
<
Object
?,
Object
?>
get
_rawValues
=>
_rawData
.
putIfAbsent
(
_valuesMapKey
,
()
=>
<
Object
?,
Object
?>{})!
as
Map
<
Object
?,
Object
?
>;
Map
<
dynamic
,
dynamic
>
get
_rawValues
=>
_rawData
.
putIfAbsent
(
_valuesMapKey
,
()
=>
<
dynamic
,
dynamic
>{})
as
Map
<
dynamic
,
dynamic
>;
// Get and store values.
// Get and store values.
...
...
packages/flutter/test/services/message_codecs_testing.dart
View file @
3c77c432
...
@@ -17,13 +17,13 @@ void checkEncoding<T>(MessageCodec<T> codec, T message, List<int> expectedBytes)
...
@@ -17,13 +17,13 @@ void checkEncoding<T>(MessageCodec<T> codec, T message, List<int> expectedBytes)
void
checkEncodeDecode
<
T
>(
MessageCodec
<
T
>
codec
,
T
message
)
{
void
checkEncodeDecode
<
T
>(
MessageCodec
<
T
>
codec
,
T
message
)
{
final
ByteData
?
encoded
=
codec
.
encodeMessage
(
message
);
final
ByteData
?
encoded
=
codec
.
encodeMessage
(
message
);
final
T
?
decoded
=
codec
.
decodeMessage
(
encoded
);
final
T
decoded
=
codec
.
decodeMessage
(
encoded
);
if
(
message
==
null
)
{
if
(
message
==
null
)
{
expect
(
encoded
,
isNull
);
expect
(
encoded
,
isNull
);
expect
(
decoded
,
isNull
);
expect
(
decoded
,
isNull
);
}
else
{
}
else
{
expect
(
deepEquals
(
message
,
decoded
),
isTrue
);
expect
(
deepEquals
(
message
,
decoded
),
isTrue
);
final
ByteData
?
encodedAgain
=
codec
.
encodeMessage
(
decoded
as
T
);
final
ByteData
?
encodedAgain
=
codec
.
encodeMessage
(
decoded
);
expect
(
expect
(
encodedAgain
!.
buffer
.
asUint8List
(),
encodedAgain
!.
buffer
.
asUint8List
(),
orderedEquals
(
encoded
!.
buffer
.
asUint8List
()),
orderedEquals
(
encoded
!.
buffer
.
asUint8List
()),
...
...
packages/flutter_web_plugins/test/plugin_registry_test.dart
View file @
3c77c432
...
@@ -56,7 +56,7 @@ void main() {
...
@@ -56,7 +56,7 @@ void main() {
final
List
<
String
>
loggedMessages
=
<
String
>[];
final
List
<
String
>
loggedMessages
=
<
String
>[];
ServicesBinding
.
instance
!.
defaultBinaryMessenger
ServicesBinding
.
instance
!.
defaultBinaryMessenger
.
setMessageHandler
(
'test_send'
,
(
ByteData
?
data
)
{
.
setMessageHandler
(
'test_send'
,
(
ByteData
?
data
)
{
loggedMessages
.
add
(
codec
.
decodeMessage
(
data
)
!
as
String
);
loggedMessages
.
add
(
codec
.
decodeMessage
(
data
)
as
String
);
return
Future
<
ByteData
?>.
value
(
null
);
return
Future
<
ByteData
?>.
value
(
null
);
});
});
...
...
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