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
53dcf92f
Unverified
Commit
53dcf92f
authored
Oct 29, 2019
by
gaaclarke
Committed by
GitHub
Oct 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug where we could accidently call a callback twice. (#43467)
parent
05c3f7b6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
2 deletions
+45
-2
binding.dart
packages/flutter/lib/src/services/binding.dart
+4
-1
default_binary_messenger_test.dart
.../flutter/test/services/default_binary_messenger_test.dart
+37
-0
plugin_registry.dart
packages/flutter_web_plugins/lib/src/plugin_registry.dart
+4
-1
No files found.
packages/flutter/lib/src/services/binding.dart
View file @
53dcf92f
...
...
@@ -200,6 +200,7 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
response
=
await
handler
(
data
);
}
else
{
ui
.
channelBuffers
.
push
(
channel
,
data
,
callback
);
callback
=
null
;
}
}
catch
(
exception
,
stack
)
{
FlutterError
.
reportError
(
FlutterErrorDetails
(
...
...
@@ -209,9 +210,11 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
context:
ErrorDescription
(
'during a platform message callback'
),
));
}
finally
{
if
(
callback
!=
null
)
{
callback
(
response
);
}
}
}
@override
Future
<
ByteData
>
send
(
String
channel
,
ByteData
message
)
{
...
...
packages/flutter/test/services/default_binary_messenger_test.dart
0 → 100644
View file @
53dcf92f
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:convert'
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
ByteData
_makeByteData
(
String
str
)
{
final
List
<
int
>
list
=
utf8
.
encode
(
str
);
final
ByteBuffer
buffer
=
list
is
Uint8List
?
list
.
buffer
:
Uint8List
.
fromList
(
list
).
buffer
;
return
ByteData
.
view
(
buffer
);
}
test
(
'default binary messenger calls callback once'
,
()
async
{
int
count
=
0
;
const
String
channel
=
'foo'
;
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
channel
,
_makeByteData
(
'bar'
),
(
ByteData
message
)
async
{
count
+=
1
;
return
null
;
});
expect
(
count
,
equals
(
0
));
await
ui
.
channelBuffers
.
drain
(
channel
,
(
ByteData
data
,
ui
.
PlatformMessageResponseCallback
callback
)
{
callback
(
null
);
return
null
;
});
expect
(
count
,
equals
(
1
));
});
}
packages/flutter_web_plugins/lib/src/plugin_registry.dart
View file @
53dcf92f
...
...
@@ -82,6 +82,7 @@ class _PlatformBinaryMessenger extends BinaryMessenger {
response
=
await
handler
(
data
);
}
else
{
ui
.
channelBuffers
.
push
(
channel
,
data
,
callback
);
callback
=
null
;
}
}
catch
(
exception
,
stack
)
{
FlutterError
.
reportError
(
FlutterErrorDetails
(
...
...
@@ -91,9 +92,11 @@ class _PlatformBinaryMessenger extends BinaryMessenger {
context:
ErrorDescription
(
'during a plugin platform message call'
),
));
}
finally
{
if
(
callback
!=
null
)
{
callback
(
response
);
}
}
}
/// Sends a platform message from the platform side back to the framework.
@override
...
...
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