migration & enhancement for Axis / AxisDirection#151771
Closed
nate-thegrate wants to merge 3 commits intoflutter:masterfrom
Closed
migration & enhancement for Axis / AxisDirection#151771nate-thegrate wants to merge 3 commits intoflutter:masterfrom
Axis / AxisDirection#151771nate-thegrate wants to merge 3 commits intoflutter:masterfrom
Conversation
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Contributor
Author
|
Closing, since this likely won't end up being necessary for #151627. (I'd love to have these enum enhancements at some point, but as of right now, it seems like the hassle outweighs the benefit.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a small change, but it still might be difficult to review.
Related:
DragGestureRecognizerabstract methods public #151446Motivation
Dependency conflict
Currently, package:flutter/painting.dart depends on package:flutter/gestures.dart, so anything within the gestures library cannot use something declared in painting (since that would create a dependency loop).
This resulted in a less-than-ideal situation: the
DragGestureRecognizerneeds to use anAxisvalue for itsprimaryDragAxisfield and itsgetSumDelta()method, but it isn't allowed to import theAxisenum.So instead, the enum was copied into the file and given a private name. All methods that use this enum have to be private as well: if someone needs a version of
PanGestureRecognizerwith a slight change to the distance required to accept the gesture, they need to copy the entireDragGestureRecognizerinterface and re-implement each abstract method before tweaking to the desired behavior.Enum enhancements
AxisandAxisDirectionwere given a few helper methods before enhanced enum features were added to Dart. This provides an opportunity for a satisfying refactor:It's much easier for me to understand the process of "convert the
AxisDirectionto anAxis, and then flip it" when it isn't a nested function call that's read from right-to-left.Summary of changes
Migration
Since painting/basic_types.dart is already exporting a type from the foundation package, the migration was more-or-less trivial: enums in that file were moved into foundation/basic_types.dart.
Deprecation
AxisandAxisDirectionwere given a.flippedgetter that corresponds toflipAxis()andflipAxisDirection()respectively.AxisDirectionalso has.axisand.isReversedthat corresponds toaxisDirectionToAxis()&axisDirectionIsReversed().I also added
@Deprecated()to the functions being replaced; unfortunately at this point we can't implement a data-driven fix for a "function → getter" migration. Perhaps instead of deprecating now, we could do something similar toWidgetStateProperty.all:flutter/packages/flutter/lib/src/widgets/widget_state.dart
Lines 552 to 555 in fbb12c2