From 70a4f2b45624516a1dfe8286f8e1052b95de5d36 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 3 Nov 2021 14:11:01 -0700 Subject: [PATCH] Provide a default handler for the flutter/navigation channel This ensures that messages sent to this channel by the framework will not be stored indefinitely if buffering is enabled. (see https://github.com/flutter/engine/pull/29377) --- .../engine/systemchannels/NavigationChannel.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java index e76023471e2bd..87e7e36fe8d9a 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java @@ -9,6 +9,7 @@ import io.flutter.Log; import io.flutter.embedding.engine.dart.DartExecutor; import io.flutter.plugin.common.JSONMethodCodec; +import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; /** TODO(mattcarroll): fill in javadoc for NavigationChannel. */ @@ -19,8 +20,19 @@ public class NavigationChannel { public NavigationChannel(@NonNull DartExecutor dartExecutor) { this.channel = new MethodChannel(dartExecutor, "flutter/navigation", JSONMethodCodec.INSTANCE); + channel.setMethodCallHandler(defaultHandler); } + // Provide a default handler that returns an empty response to any messages + // on this channel. + private final MethodChannel.MethodCallHandler defaultHandler = + new MethodChannel.MethodCallHandler() { + @Override + public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { + result.success(null); + } + }; + public void setInitialRoute(@NonNull String initialRoute) { Log.v(TAG, "Sending message to set initial route to '" + initialRoute + "'"); channel.invokeMethod("setInitialRoute", initialRoute);