Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
NavigationChannel.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.embedding.engine.systemchannels;
6
7import androidx.annotation.NonNull;
8import androidx.annotation.Nullable;
9import io.flutter.Log;
10import io.flutter.embedding.engine.dart.DartExecutor;
11import io.flutter.plugin.common.JSONMethodCodec;
12import io.flutter.plugin.common.MethodCall;
13import io.flutter.plugin.common.MethodChannel;
14import java.util.HashMap;
15import java.util.Map;
16
17/** TODO(mattcarroll): fill in javadoc for NavigationChannel. */
18public class NavigationChannel {
19 private static final String TAG = "NavigationChannel";
20
21 @NonNull public final MethodChannel channel;
22
23 public NavigationChannel(@NonNull DartExecutor dartExecutor) {
24 this.channel = new MethodChannel(dartExecutor, "flutter/navigation", JSONMethodCodec.INSTANCE);
25 channel.setMethodCallHandler(defaultHandler);
26 }
27
28 // Provide a default handler that returns an empty response to any messages
29 // on this channel.
30 private final MethodChannel.MethodCallHandler defaultHandler =
31 new MethodChannel.MethodCallHandler() {
32 @Override
33 public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
34 result.success(null);
35 }
36 };
37
38 public void setInitialRoute(@NonNull String initialRoute) {
39 Log.v(TAG, "Sending message to set initial route to '" + initialRoute + "'");
40 channel.invokeMethod("setInitialRoute", initialRoute);
41 }
42
43 public void pushRoute(@NonNull String route) {
44 Log.v(TAG, "Sending message to push route '" + route + "'");
45 channel.invokeMethod("pushRoute", route);
46 }
47
48 public void pushRouteInformation(@NonNull String route) {
49 Log.v(TAG, "Sending message to push route information '" + route + "'");
50 Map<String, String> message = new HashMap<>();
51 message.put("location", route);
52 channel.invokeMethod("pushRouteInformation", message);
53 }
54
55 public void popRoute() {
56 Log.v(TAG, "Sending message to pop route.");
57 channel.invokeMethod("popRoute", null);
58 }
59
60 public void setMethodCallHandler(@Nullable MethodChannel.MethodCallHandler handler) {
61 channel.setMethodCallHandler(handler);
62 }
63}
static void v(@NonNull String tag, @NonNull String message)
Definition Log.java:40
void setMethodCallHandler(@Nullable MethodChannel.MethodCallHandler handler)
static ::testing::Matcher< GBytes * > MethodCall(const std::string &name, ::testing::Matcher< FlValue * > args)
GAsyncResult * result
Win32Message message
#define TAG()