pages.dart 1.24 KB
Newer Older
1 2 3 4 5 6
// Copyright 2015 The Chromium 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 'dart:async';

7
import 'basic.dart';
8 9 10 11 12 13 14 15
import 'navigator.dart';
import 'overlay.dart';
import 'routes.dart';

/// A modal route that replaces the entire screen.
abstract class PageRoute<T> extends ModalRoute<T> {
  PageRoute({
    Completer<T> completer,
16
    RouteSettings settings: const RouteSettings()
17
  }) : super(completer: completer, settings: settings);
18 19

  @override
20
  bool get opaque => true;
21 22

  @override
23
  bool get barrierDismissable => false;
24 25

  @override
26
  bool canTransitionTo(TransitionRoute<dynamic> nextRoute) => nextRoute is PageRoute<dynamic>;
27 28

  @override
29
  bool canTransitionFrom(TransitionRoute<dynamic> nextRoute) => nextRoute is PageRoute<dynamic>;
30

31
  @override
32 33
  AnimationController createAnimationController() {
    AnimationController controller = super.createAnimationController();
34
    if (settings.isInitialRoute)
35 36
      controller.value = 1.0;
    return controller;
37 38
  }

39
  /// Subclasses can override this method to customize how heroes are inserted.
40 41 42
  void insertHeroOverlayEntry(OverlayEntry entry, Object tag, OverlayState overlay) {
    overlay.insert(entry);
  }
43
}