Thanks to visit codestin.com
Credit goes to github.com

Skip to content

const AnimationStyle #160564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2025
Merged

Conversation

nate-thegrate
Copy link
Contributor

AnimationStyle is an @immutable class with all final fields.

This pull request gives it a const constructor.


related: #160563

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. a: animation Animation APIs f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Dec 19, 2024
@nate-thegrate

This comment was marked as resolved.

@nate-thegrate
Copy link
Contributor Author

nate-thegrate commented Jan 8, 2025

We should be able to land this once flutter/packages#8397 is merged.

(Edit: it's been merged!)

auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 14, 2025
unblocks flutter/flutter#160564

Will go back through and implement `const` constructors in these spots once the framework PR lands.
@nate-thegrate nate-thegrate force-pushed the const-AnimationStyle branch 3 times, most recently from cdeb849 to 3ce2ee3 Compare January 14, 2025 23:51
@Piinks Piinks force-pushed the const-AnimationStyle branch from 3ce2ee3 to a8dd59e Compare January 15, 2025 19:43
@Piinks Piinks removed the f: material design flutter/packages/flutter/material repository. label Jan 15, 2025
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -28,10 +28,10 @@ import 'tween.dart';
@immutable
class AnimationStyle with Diagnosticable {
/// Creates an instance of Animation Style class.
AnimationStyle({this.curve, this.duration, this.reverseCurve, this.reverseDuration});
const AnimationStyle({this.curve, this.duration, this.reverseCurve, this.reverseDuration});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised that the prefer_const_constructors_in_immutables lint didn't complain about the missing non-const constructor. Could you file an issue at https://github.com/dart-lang/sdk/issues for this (if you can, they'd appreciate a small code snippet that reproduces the lint not triggering)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait—I think I figured out why!

In order for the rule to be triggered, Diagnosticable would also need to be marked as @immutable. Choosing not to trigger the rule in a situation like this one makes the codebase less likely to break if someone adds a member variable to the mixin in the future.

(I tried giving Diagnosticable the annotation, but a bunch of errors popped up due to non-final fields in State subtypes.)

@nate-thegrate nate-thegrate added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 22, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Jan 22, 2025
Merged via the queue into flutter:master with commit 06c3c93 Jan 22, 2025
103 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 22, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 23, 2025
…8482)

Manual roll Flutter from b9e86a565f92 to b2f515f45ef5 (42 revisions)

Manual roll requested by [email protected]

flutter/flutter@b9e86a5...b2f515f

2025-01-22 [email protected] Roll Dart to Version 3.8.0-24.0.dev (flutter/flutter#162035)
2025-01-22 [email protected] `const AnimationStyle` (flutter/flutter#160564)
2025-01-22 [email protected] Add piping and bringup nodes for `_vulkan` and `_opengles` suites. (flutter/flutter#162020)
2025-01-22 [email protected] [Impeller] Migrate unit tests off of Skia geometry classes (flutter/flutter#161855)
2025-01-22 [email protected] Experiment with a `files-changed.json` per PR (flutter/flutter#161788)
2025-01-22 [email protected] Move FlKeyboardManager and FlKeyboardHandler from FlView to FlEngine. (flutter/flutter#161925)
2025-01-22 [email protected] Roll Packages from e8f1f63 to 3d3ab7b (1 revision) (flutter/flutter#162019)
2025-01-22 [email protected] Adds cupertino picker semantics test (flutter/flutter#161768)
2025-01-22 [email protected] [web] Remove deprecated web-only APIs from dart:ui (flutter/flutter#161775)
2025-01-22 [email protected] fix: Add enabled property for search anchor named constructor (flutter/flutter#161468)
2025-01-22 [email protected] Roll pub packages (flutter/flutter#162015)
2025-01-22 [email protected] [web] Remove spam from test output (flutter/flutter#161774)
2025-01-22 [email protected] Match CupertinoPageTransitionsBuilder animation duration to CupertinoPageRoute (2) (flutter/flutter#161577)
2025-01-22 [email protected] Make `font-subset` a standalone `run_tests.py` variant. (flutter/flutter#162016)
2025-01-22 [email protected] Enabled provisioning updates and device registration during building xcarchive. (flutter/flutter#159622)
2025-01-22 [email protected] [web] Remove HTML from bots, test suites and e2e tests (flutter/flutter#161537)
2025-01-22 [email protected] Expand the `.ci.yaml` and `builder.json` linter (flutter/flutter#161991)
2025-01-22 [email protected] Fix incorrect [enabled] documentation (flutter/flutter#161650)
2025-01-22 [email protected] Add `windows_host_engine_test`. (flutter/flutter#161992)
2025-01-22 [email protected] Roll Dart to version Version 3.8.0-19.0.dev (flutter/flutter#161989)
2025-01-22 [email protected] Deprecate `ThemeData.indicatorColor` in favor of `TabBarThemeData.indicatorColor` (flutter/flutter#160024)
2025-01-22 [email protected] [Impeller] disable older xclipse gpu driver. (flutter/flutter#161981)
2025-01-22 [email protected] Merge changelog for 3.27.3 release (flutter/flutter#161977)
2025-01-21 [email protected] Remove FlKeyboardViewDelegate (flutter/flutter#161705)
2025-01-21 [email protected] Fix documentation of Flow.clipBehavior (flutter/flutter#161863)
2025-01-21 [email protected] [impeller] prevent PowerVR from using Vulkan backend. (flutter/flutter#161841)
2025-01-21 [email protected] [Impeller] backfilling TextContents unit tests (flutter/flutter#161625)
2025-01-21 [email protected] Do not handle Dart isolate messages if the isolate is being shut down (flutter/flutter#161824)
2025-01-21 [email protected] fix failing lint : findByPath requires a specific ordering of project evaluation in `aar_init_script.gradle` (flutter/flutter#159301)
2025-01-21 [email protected] Get `et` working for local web engine builds. (flutter/flutter#161825)
2025-01-21 [email protected] Mark Linux_pixel_7pro flavors_test unflaky (flutter/flutter#160994)
2025-01-21 [email protected] Marks Mac_mokey run_debug_test_android to be flaky (flutter/flutter#161656)
2025-01-21 [email protected] Don't crash flutter tool if Chrome is not available (flutter/flutter#154941)
2025-01-21 [email protected] Fix DropdownMenu icon and item icon misalignment (flutter/flutter#161717)
2025-01-21 [email protected] [native assets] Cleanup dead code 2 (flutter/flutter#161916)
2025-01-21 [email protected] Update `ListTile` test to prevent log dump and test error message. (flutter/flutter#161811)
2025-01-21 [email protected] Roll pub packages (flutter/flutter#161924)
2025-01-21 [email protected] Make `PipelineOwner` a `base` class (flutter/flutter#161789)
2025-01-20 [email protected] [native assets] Cleanup dead code (flutter/flutter#161913)
2025-01-20 [email protected] Roll Packages from f73cb00 to e8f1f63 (9 revisions) (flutter/flutter#161914)
2025-01-20 [email protected] [ flutter_tool ] Fix flakiness in doctor_test.dart (flutter/flutter#161917)
2025-01-19 [email protected] Update documentation on what display information is provided. (flutter/flutter#161785)

If this roll has caused a breakage, revert this CL and stop the roller
...
@nate-thegrate nate-thegrate deleted the const-AnimationStyle branch January 24, 2025 02:58
Wasmund1 pushed a commit to Wasmund1/flutter that referenced this pull request Jan 24, 2025
[**AnimationStyle**](https://main-api.flutter.dev/flutter/animation/AnimationStyle-class.html)
is an
[`@immutable`](https://main-api.flutter.dev/flutter/meta/immutable-constant.html)
class with all `final` fields.

This pull request gives it a `const` constructor.

<br>

related: flutter#160563
@nate-thegrate nate-thegrate added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: animation Animation APIs autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants