From ef5beeced36538200cba813b42bbd43d396a19be Mon Sep 17 00:00:00 2001 From: Pierre-Louis <6655696+guidezpl@users.noreply.github.com> Date: Thu, 18 Jan 2024 09:38:00 -0800 Subject: [PATCH] Deprecate M2 curves (#134417) These have 1:1 replacements with a new name, introduced in https://github.com/flutter/flutter/pull/129942 Land after https://github.com/flutter/packages/pull/4898 Part of https://github.com/flutter/flutter/issues/116525 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- .../fix_data/fix_material/fix_material.yaml | 12 +++++----- packages/flutter/lib/src/material/curves.dart | 23 +++++++++++++++---- .../flutter/test_fixes/material/material.dart | 9 ++++---- .../test_fixes/material/material.dart.expect | 9 ++++---- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/packages/flutter/lib/fix_data/fix_material/fix_material.yaml b/packages/flutter/lib/fix_data/fix_material/fix_material.yaml index fb8467c0c8..f11926a2d6 100644 --- a/packages/flutter/lib/fix_data/fix_material/fix_material.yaml +++ b/packages/flutter/lib/fix_data/fix_material/fix_material.yaml @@ -897,9 +897,9 @@ transforms: oldName: 'showTrackOnHover' newName: 'trackVisibility' - # Changes made in https://github.com/flutter/flutter/pull/129942 + # Changes made in https://github.com/flutter/flutter/pull/134417 - title: "Migrate to 'Easing.legacy'" - date: 2023-07-04 + date: 2023-12-12 element: uris: [ 'material.dart' ] variable: 'standardEasing' @@ -910,9 +910,9 @@ transforms: field: legacy inClass: Easing - # Changes made in https://github.com/flutter/flutter/pull/129942 + # Changes made in https://github.com/flutter/flutter/pull/134417 - title: "Migrate to 'Easing.legacyAccelerate'" - date: 2023-07-04 + date: 2023-12-12 element: uris: [ 'material.dart' ] variable: 'accelerateEasing' @@ -923,9 +923,9 @@ transforms: field: legacyAccelerate inClass: Easing - # Changes made in https://github.com/flutter/flutter/pull/129942 + # Changes made in https://github.com/flutter/flutter/pull/134417 - title: "Migrate to 'Easing.legacyDecelerate'" - date: 2023-07-04 + date: 2023-12-12 element: uris: [ 'material.dart' ] variable: 'decelerateEasing' diff --git a/packages/flutter/lib/src/material/curves.dart b/packages/flutter/lib/src/material/curves.dart index c267e3771e..3c465e5019 100644 --- a/packages/flutter/lib/src/material/curves.dart +++ b/packages/flutter/lib/src/material/curves.dart @@ -6,9 +6,7 @@ import 'package:flutter/animation.dart'; // The easing curves of the Material Library -// TODO(guidezpl): deprecate the three curves below once customers (packages/plugins) are migrated - -/// The standard easing curve in the Material specification. +/// The standard easing curve in the Material 2 specification. /// /// Elements that begin and end at rest use standard easing. /// They speed up quickly and slow down gradually, in order @@ -16,18 +14,28 @@ import 'package:flutter/animation.dart'; /// /// See also: /// * +@Deprecated( + 'Use Easing.legacy (M2) or Easing.standard (M3) instead. ' + 'This curve is updated in M3. ' + 'This feature was deprecated after v3.18.0-0.1.pre.' +) const Curve standardEasing = Curves.fastOutSlowIn; -/// The accelerate easing curve in the Material specification. +/// The accelerate easing curve in the Material 2 specification. /// /// Elements exiting a screen use acceleration easing, /// where they start at rest and end at peak velocity. /// /// See also: /// * +@Deprecated( + 'Use Easing.legacyAccelerate (M2) or Easing.standardAccelerate (M3) instead. ' + 'This curve is updated in M3. ' + 'This feature was deprecated after v3.18.0-0.1.pre.' +) const Curve accelerateEasing = Cubic(0.4, 0.0, 1.0, 1.0); -/// The decelerate easing curve in the Material specification. +/// The decelerate easing curve in the Material 2 specification. /// /// Incoming elements are animated using deceleration easing, /// which starts a transition at peak velocity (the fastest @@ -35,4 +43,9 @@ const Curve accelerateEasing = Cubic(0.4, 0.0, 1.0, 1.0); /// /// See also: /// * +@Deprecated( + 'Use Easing.legacyDecelerate (M2) or Easing.standardDecelerate (M3) instead. ' + 'This curve is updated in M3. ' + 'This feature was deprecated after v3.18.0-0.1.pre.' +) const Curve decelerateEasing = Cubic(0.0, 0.0, 0.2, 1.0); diff --git a/packages/flutter/test_fixes/material/material.dart b/packages/flutter/test_fixes/material/material.dart index 3afb419e54..48928a96f8 100644 --- a/packages/flutter/test_fixes/material/material.dart +++ b/packages/flutter/test_fixes/material/material.dart @@ -318,11 +318,10 @@ void main() { ); final Clip clip = details.clipBehavior; - // Changes made in https://github.com/flutter/flutter/pull/129942 - // TODO(guidezpl): enable fix after https://github.com/dart-lang/sdk/issues/52902 - // const Curve curve = standardEasing; expect Easing.legacy - // const Curve curve = accelerateEasing; expect Easing.legacyAccelerate - // const Curve curve = decelerateEasing; expect Easing.legacyDecelerate + // Changes made in https://github.com/flutter/flutter/pull/134417 + const Curve curve = standardEasing; + const Curve curve = accelerateEasing; + const Curve curve = decelerateEasing; final PlatformMenuBar platformMenuBar = PlatformMenuBar(menus: [], body: const SizedBox()); final Widget bodyValue = platformMenuBar.body; diff --git a/packages/flutter/test_fixes/material/material.dart.expect b/packages/flutter/test_fixes/material/material.dart.expect index 1c475a47f5..fc8f42404e 100644 --- a/packages/flutter/test_fixes/material/material.dart.expect +++ b/packages/flutter/test_fixes/material/material.dart.expect @@ -314,11 +314,10 @@ void main() { ); final Clip clip = details.decorationClipBehavior; - // Changes made in https://github.com/flutter/flutter/pull/129942 - // TODO(guidezpl): enable fix after https://github.com/dart-lang/sdk/issues/52902 - // const Curve curve = standardEasing; expect Easing.legacy - // const Curve curve = accelerateEasing; expect Easing.legacyAccelerate - // const Curve curve = decelerateEasing; expect Easing.legacyDecelerate + // Changes made in https://github.com/flutter/flutter/pull/134417 + const Curve curve = Easing.legacy; + const Curve curve = Easing.legacyAccelerate; + const Curve curve = Easing.legacyDecelerate; final PlatformMenuBar platformMenuBar = PlatformMenuBar(menus: [], child: const SizedBox()); final Widget bodyValue = platformMenuBar.child;