mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Check for a detached FlutterNativeView before sending messages (#4445)
Fixes https://github.com/flutter/flutter/issues/13481
This commit is contained in:
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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user