• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
5 package io.flutter.embedding.engine.systemchannels;
6 
7 import android.support.annotation.NonNull;
8 import android.support.annotation.Nullable;
9 
10 import io.flutter.Log;
11 import io.flutter.embedding.engine.dart.DartExecutor;
12 import io.flutter.plugin.common.JSONMethodCodec;
13 import io.flutter.plugin.common.MethodChannel;
14 
15 /**
16  * TODO(mattcarroll): fill in javadoc for NavigationChannel.
17  */
18 public class NavigationChannel {
19   private static final String TAG = "NavigationChannel";
20 
21   @NonNull
22   public final MethodChannel channel;
23 
NavigationChannel(@onNull DartExecutor dartExecutor)24   public NavigationChannel(@NonNull DartExecutor dartExecutor) {
25     this.channel = new MethodChannel(dartExecutor, "flutter/navigation", JSONMethodCodec.INSTANCE);
26   }
27 
setInitialRoute(@onNull String initialRoute)28   public void setInitialRoute(@NonNull String initialRoute) {
29     Log.v(TAG, "Sending message to set initial route to '" + initialRoute + "'");
30     channel.invokeMethod("setInitialRoute", initialRoute);
31   }
32 
pushRoute(@onNull String route)33   public void pushRoute(@NonNull String route) {
34     Log.v(TAG, "Sending message to push route '" + route + "'");
35     channel.invokeMethod("pushRoute", route);
36   }
37 
popRoute()38   public void popRoute() {
39     Log.v(TAG, "Sending message to pop route.");
40     channel.invokeMethod("popRoute", null);
41   }
42 
setMethodCallHandler(@ullable MethodChannel.MethodCallHandler handler)43   public void setMethodCallHandler(@Nullable MethodChannel.MethodCallHandler handler) {
44     channel.setMethodCallHandler(handler);
45   }
46 
47 }
48