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

Fixes https://github.com/flutter/flutter/issues/13481
This commit is contained in:
Jason Simmons
2017-12-11 17:15:21 -08:00
committed by GitHub
parent 9f8cf7eb97
commit aaa758d619
@@ -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);
}