-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute_notification_messages.dart
45 lines (40 loc) · 1.47 KB
/
route_notification_messages.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'navigator.dart';
/// Messages for route change notifications.
class RouteNotificationMessages {
// This class is not meant to be instatiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
RouteNotificationMessages._();
/// When the engine is Web notify the platform for a route change.
static void maybeNotifyRouteChange(String methodName, Route<dynamic> route, Route<dynamic> previousRoute) {
if(kIsWeb) {
_notifyRouteChange(methodName, route, previousRoute);
} else {
// No op.
}
}
/// Notifies the platform of a route change.
///
/// There are three methods: 'routePushed', 'routePopped', 'routeReplaced'.
///
/// See also:
///
/// * [SystemChannels.navigation], which handles subsequent navigation
/// requests.
static void _notifyRouteChange(String methodName, Route<dynamic> route, Route<dynamic> previousRoute) {
final String previousRouteName = previousRoute?.settings?.name;
final String routeName = route?.settings?.name;
SystemChannels.navigation.invokeMethod<void>(
methodName,
<String, dynamic>{
'previousRouteName': previousRouteName,
'routeName': routeName,
},
);
}
}