pages.dart 1.16 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 8
import 'package:flutter/animation.dart';

9 10 11 12 13 14 15 16
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,
17
    RouteSettings settings: const RouteSettings()
18 19 20 21 22
  }) : super(completer: completer, settings: settings);
  bool get opaque => true;
  bool get barrierDismissable => false;
  bool canTransitionTo(TransitionRoute nextRoute) => nextRoute is PageRoute;
  bool canTransitionFrom(TransitionRoute nextRoute) => nextRoute is PageRoute;
23

24 25 26 27 28 29 30
  Performance createPerformanceController() {
    Performance performance = super.createPerformanceController();
    if (settings.isInitialRoute)
      performance.progress = 1.0;
    return performance;
  }

31
  /// Subclasses can override this method to customize how heroes are inserted.
32 33 34
  void insertHeroOverlayEntry(OverlayEntry entry, Object tag, OverlayState overlay) {
    overlay.insert(entry);
  }
35
}