Cleanup PageTransitionsTheme documentation and add one example (#121701)

Cleanup PageTransitionsTheme documentation and add one example
This commit is contained in:
Bruno Leroux
2023-03-02 21:47:53 +01:00
committed by GitHub
parent 50c80d9b50
commit a4ecd3e2f1
3 changed files with 153 additions and 10 deletions

View File

@@ -151,7 +151,7 @@ class _OpenUpwardsPageTransition extends StatelessWidget {
class _ZoomPageTransition extends StatelessWidget {
/// Creates a [_ZoomPageTransition].
///
/// The [animation] and [secondaryAnimation] argument are required and must
/// The [animation] and [secondaryAnimation] arguments are required and must
/// not be null.
const _ZoomPageTransition({
required this.animation,
@@ -196,9 +196,15 @@ class _ZoomPageTransition extends StatelessWidget {
/// Whether the [SnapshotWidget] will be used.
///
/// Notably, this improves performance by disabling animations on both the outgoing and
/// incoming route. This also implies that ink-splashes or similar animations will
/// not animate during the transition.
/// When this value is true, performance is improved by disabling animations
/// on both the outgoing and incoming route. This also implies that ink-splashes
/// or similar animations will not animate during the transition.
///
/// See also:
///
/// * [TransitionRoute.allowSnapshotting], which defines wether the route
/// transition will prefer to animate a snapshot of the entering and exiting
/// routes.
final bool allowSnapshotting;
/// The widget below this widget in the tree.
@@ -669,7 +675,13 @@ class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder {
/// and delegates to [buildTransitions].
///
/// If a builder with a matching platform is not found, then the
/// [FadeUpwardsPageTransitionsBuilder] is used.
/// [ZoomPageTransitionsBuilder] is used.
///
/// {@tool dartpad}
/// This example shows a [MaterialApp] that defines a custom [PageTransitionsTheme].
///
/// ** See code in examples/api/lib/material/page_transitions_theme/page_transitions_theme.0.dart **
/// {@end-tool}
///
/// See also:
///
@@ -702,8 +714,9 @@ class PageTransitionsTheme with Diagnosticable {
Map<TargetPlatform, PageTransitionsBuilder> get builders => _builders;
final Map<TargetPlatform, PageTransitionsBuilder> _builders;
/// Delegates to the builder for the current [ThemeData.platform]
/// or [ZoomPageTransitionsBuilder].
/// Delegates to the builder for the current [ThemeData.platform].
/// If a builder for the current platform is not found, then the
/// [ZoomPageTransitionsBuilder] is used.
///
/// [MaterialPageRoute.buildTransitions] delegates to this method.
Widget buildTransitions<T>(
@@ -724,8 +737,8 @@ class PageTransitionsTheme with Diagnosticable {
return matchingBuilder.buildTransitions<T>(route, context, animation, secondaryAnimation, child);
}
// Just used to the builders Map to a list with one PageTransitionsBuilder per platform
// for the operator == overload.
// Map the builders to a list with one PageTransitionsBuilder per platform for
// the operator == overload.
List<PageTransitionsBuilder?> _all(Map<TargetPlatform, PageTransitionsBuilder> builders) {
return TargetPlatform.values.map((TargetPlatform platform) => builders[platform]).toList();
}
@@ -968,7 +981,9 @@ class _ZoomExitTransitionPainter extends SnapshotPainter {
@override
bool shouldRepaint(covariant _ZoomExitTransitionPainter oldDelegate) {
return oldDelegate.reverse != reverse || oldDelegate.fade.value != fade.value || oldDelegate.scale.value != scale.value;
return oldDelegate.reverse != reverse
|| oldDelegate.fade.value != fade.value
|| oldDelegate.scale.value != scale.value;
}
@override