Skip to content

Commit 1820a05

Browse files
committed
don't use withUnsafeBytes(of:), seems to not work properly on Linux
1 parent e47e617 commit 1820a05

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Sources/FlutterSwift/Messenger/FlutterDesktopMessenger.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public actor FlutterDesktopMessenger: FlutterBinaryMessenger {
6464
) throws {
6565
precondition(isAvailable)
6666

67-
guard withUnsafeBytes(of: message, { bytes in
67+
let message = [UInt8](message ?? Data())
68+
69+
guard message.withUnsafeBytes({ bytes in
6870
// run on main actor, so don't need to take lock
6971
FlutterDesktopMessengerSendWithReplyBlock(
7072
messenger,
@@ -101,12 +103,13 @@ public actor FlutterDesktopMessenger: FlutterBinaryMessenger {
101103
}
102104

103105
// FIXME: do we need to take a lock here? doesn't look like other platforms do
104-
withUnsafeBytes(of: response) {
106+
let response = [UInt8](response ?? Data())
107+
response.withUnsafeBytes {
105108
FlutterDesktopMessengerSendResponse(
106109
messenger,
107110
handle,
108111
$0.baseAddress,
109-
response?.count ?? 0
112+
response.count
110113
)
111114
}
112115
}

0 commit comments

Comments
 (0)