Skip to content

Commit

Permalink
Provide a default handler for the flutter/navigation channel (flutter…
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons committed Nov 4, 2021
1 parent 32fff2f commit 5140e30
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -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. */
Expand All @@ -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);
Expand Down

0 comments on commit 5140e30

Please sign in to comment.