refactor: Migrate Expansible animation properties to AnimationStyle for a less broad API surface#177966
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Expansible widget to use AnimationStyle for its animation properties, deprecating the older duration, curve, and reverseCurve properties. This change aligns Expansible with other Flutter widgets and aims for a cleaner API surface. The implementation includes the necessary widget updates, data-driven fixes for smooth user migration, and new tests. My review found a couple of areas for improvement: the documentation for the new animationStyle property is confusing and contains an error, and a test case could be made more explicit to better reflect its purpose. Overall, this is a good refactoring that improves API consistency.
| /// If [AnimationStyle.duration] or [AnimationStyle.reverseDuration] is | ||
| /// provided, it will be used to override [duration]. If it is null, then | ||
| /// [duration] will be used. Otherwise, defaults to 200ms. |
There was a problem hiding this comment.
This documentation paragraph is confusing and contains an error. It incorrectly mentions AnimationStyle.reverseDuration, which is not used by Expansible. The phrasing with If it is null and Otherwise is also ambiguous.
Please consider rephrasing for clarity. The following paragraphs for curve and reverseCurve have similar clarity issues.
/// If [AnimationStyle.duration] is provided, it will be used instead of
/// [duration]. If not provided, [duration] is used, which defaults to
/// 200ms.There was a problem hiding this comment.
This is an interesting question. I wonder, should Expansible support reverse duration? Maybe for closing? Or would that potentially be confusing based on the initial state?
There was a problem hiding this comment.
It does have a reverse curve, so I guess reverse duration would apply in that scenario. Probably good to consider as a separate change rather than lumped with this one. :)
There was a problem hiding this comment.
Yes, I will update comment here and add reverseDuration in upcoming PR(if required).
| testWidgets('AnimationStyle takes precedence over deprecated properties', ( | ||
| WidgetTester tester, | ||
| ) async { |
There was a problem hiding this comment.
This test is correctly named 'AnimationStyle takes precedence over deprecated properties', but it only implicitly tests this by checking that animationStyle overrides the default values of the deprecated properties. To make the test's intent more explicit and robust, consider explicitly passing values for the deprecated duration and curve properties in the Expansible constructor and asserting they are ignored.
1fb8a30 to
462c61f
Compare
victorsanni
left a comment
There was a problem hiding this comment.
linux analyze is failing because packages/flutter/test_fixes/widgets/widgets.dart isn't formatted correctly.
89fe6a2 to
382c2f2
Compare
382c2f2 to
35baecd
Compare
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…nStyle for a less broad API surface (flutter/flutter#177966)
…or a less broad API surface (flutter#177966) * Add animationStyle to Exapnsible * Mark duration, curve and reverseCurve as deprecated * Add data driven fixes fixes: flutter#177799 - [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] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
…or a less broad API surface (flutter#177966) ## Changes * Add animationStyle to Exapnsible * Mark duration, curve and reverseCurve as deprecated * Add data driven fixes fixes: flutter#177799 ## 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] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
…or a less broad API surface (flutter#177966) ## Changes * Add animationStyle to Exapnsible * Mark duration, curve and reverseCurve as deprecated * Add data driven fixes fixes: flutter#177799 ## 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] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
…nStyle for a less broad API surface (flutter/flutter#177966)
Changes
fixes: #177799
Pre-launch Checklist
///).