
This extracts the sample code out from the API doc comments, and places them in separate files on disk, allowing running of the examples locally, testing them, and building of slightly larger examples.
70 lines
2.9 KiB
Dart
70 lines
2.9 KiB
Dart
// 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.
|
|
|
|
// Template: dev/snippets/config/templates/freeform.tmpl
|
|
//
|
|
// Comment lines marked with "▼▼▼" and "▲▲▲" are used for authoring
|
|
// of samples, and may be ignored if you are just exploring the sample.
|
|
|
|
// Flutter code sample for TransitionDelegate
|
|
//
|
|
//***************************************************************************
|
|
//* ▼▼▼▼▼▼▼▼ description ▼▼▼▼▼▼▼▼ (do not modify or remove section marker)
|
|
|
|
// The following example demonstrates how to implement a subclass that always
|
|
// removes or adds routes without animated transitions and puts the removed
|
|
// routes at the top of the list.
|
|
|
|
//* ▲▲▲▲▲▲▲▲ description ▲▲▲▲▲▲▲▲ (do not modify or remove section marker)
|
|
//***************************************************************************
|
|
|
|
//****************************************************************************
|
|
//* ▼▼▼▼▼▼▼▼ code-imports ▼▼▼▼▼▼▼▼ (do not modify or remove section marker)
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
//* ▲▲▲▲▲▲▲▲ code-imports ▲▲▲▲▲▲▲▲ (do not modify or remove section marker)
|
|
//****************************************************************************
|
|
|
|
//********************************************************************
|
|
//* ▼▼▼▼▼▼▼▼ code ▼▼▼▼▼▼▼▼ (do not modify or remove section marker)
|
|
|
|
class NoAnimationTransitionDelegate extends TransitionDelegate<void> {
|
|
@override
|
|
Iterable<RouteTransitionRecord> resolve({
|
|
required List<RouteTransitionRecord> newPageRouteHistory,
|
|
required Map<RouteTransitionRecord?, RouteTransitionRecord>
|
|
locationToExitingPageRoute,
|
|
required Map<RouteTransitionRecord?, List<RouteTransitionRecord>>
|
|
pageRouteToPagelessRoutes,
|
|
}) {
|
|
final List<RouteTransitionRecord> results = <RouteTransitionRecord>[];
|
|
|
|
for (final RouteTransitionRecord pageRoute in newPageRouteHistory) {
|
|
if (pageRoute.isWaitingForEnteringDecision) {
|
|
pageRoute.markForAdd();
|
|
}
|
|
results.add(pageRoute);
|
|
}
|
|
for (final RouteTransitionRecord exitingPageRoute
|
|
in locationToExitingPageRoute.values) {
|
|
if (exitingPageRoute.isWaitingForExitingDecision) {
|
|
exitingPageRoute.markForRemove();
|
|
final List<RouteTransitionRecord>? pagelessRoutes =
|
|
pageRouteToPagelessRoutes[exitingPageRoute];
|
|
if (pagelessRoutes != null) {
|
|
for (final RouteTransitionRecord pagelessRoute in pagelessRoutes) {
|
|
pagelessRoute.markForRemove();
|
|
}
|
|
}
|
|
}
|
|
results.add(exitingPageRoute);
|
|
}
|
|
return results;
|
|
}
|
|
}
|
|
|
|
//* ▲▲▲▲▲▲▲▲ code ▲▲▲▲▲▲▲▲ (do not modify or remove section marker)
|
|
//********************************************************************
|