未验证 提交 aaa758d6 编写于 作者: J Jason Simmons 提交者: GitHub

Check for a detached FlutterNativeView before sending messages (#4445)

Fixes https://github.com/flutter/flutter/issues/13481
上级 9f8cf7eb
......@@ -588,11 +588,12 @@ public class FlutterView extends SurfaceView
}
private boolean isAttached() {
return mNativeView.isAttached();
return mNativeView != null && mNativeView.isAttached();
}
void assertAttached() {
mNativeView.assertAttached();
if (!isAttached())
throw new AssertionError("Platform view is not attached");
}
private void preRun() {
......@@ -857,11 +858,15 @@ public class FlutterView extends SurfaceView
@Override
public void send(String channel, ByteBuffer message) {
mNativeView.send(channel, message);
send(channel, message, null);
}
@Override
public void send(String channel, ByteBuffer message, BinaryReply callback) {
if (!isAttached()) {
Log.d(TAG, "FlutterView.send called on a detached view, channel=" + channel);
return;
}
mNativeView.send(channel, message, callback);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册