Add smoke tests for all the examples, fix 17 broken examples. (#89021)
This adds a smoke test for every single API example. It also fixes 17 tests that had bugs in them, or were otherwise broken, and even fixes one actual bug in the framework, and one limitation in the framework. The bug in the framework is that NetworkImage's _loadAsync method had await response.drain<List<int>>();, but if the response is null, it will throw a cryptic exception saying that Null can't be assigned to List<int>. The fix was just to use await response.drain<void>(); instead. The limitation is that RelativePositionedTransition takes an Animation<Rect> rect parameter, and if you want to use a RectTween with it, the value emitted there is Rect?, and one of the examples was just casting from Animation<Rect> to Animation<Rect?>, which is invalid, so I modified RelativePositionedTransition to take a Rect? and just use Rect.zero if the rect is null.
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
// 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)
|
||||
//********************************************************************
|
||||
Reference in New Issue
Block a user