parent
dfa489c394
commit
30f8d3b392
@ -37,7 +37,13 @@ class BinaryMessages {
|
||||
|
||||
static Future<ByteData> _sendPlatformMessage(String channel, ByteData message) {
|
||||
final Completer<ByteData> completer = Completer<ByteData>();
|
||||
ServicesBinding.instance.window.sendPlatformMessage(channel, message, (ByteData reply) {
|
||||
// ui.window is accessed directly instead of using ServicesBinding.instance.window
|
||||
// because this method might be invoked before any binding is initialized.
|
||||
// This issue was reported in #27541. It is not ideal to statically access
|
||||
// ui.window because the Window may be dependency injected elsewhere with
|
||||
// a different instance. However, static access at this location seems to be
|
||||
// the least bad option.
|
||||
ui.window.sendPlatformMessage(channel, message, (ByteData reply) {
|
||||
try {
|
||||
completer.complete(reply);
|
||||
} catch (exception, stack) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user