Decode empty message to nil in standard codec (#25064)
This updates Flutter.*Codec `decode:` implementations to treat empty messages as equivalent to nil or NSNull, which avoids a crash when we subsequently otherwise try to read the type/value from the message. This handles the case where the sender were to send `null` over the channel. e.g., final channel = BasicMessageChannel<Object?>('somechannel', StandardMessageCodec()); channel.send(null); It also updates the macOS embedder to send nil to the decoder when a zero-length message is received in order to be consistent with the iOS embedding. Previously, the macOS embedder always encoded platform messages as NSData regardless of length: https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm#L498-L500 The iOS embedder did not have this issue since it special-cased zero-length messages as nil: https://github.com/flutter/engine/blob/ba93431e6885f94614d91c291ae0336bac6b70b0/shell/platform/darwin/ios/framework/Source/platform_message_router.mm#L23-L26 Bug: https://github.com/flutter/flutter/issues/78003
Showing
想要评论请 注册 或 登录