-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
Replace CustomPoint with extension methods on Point #1585
Replace CustomPoint with extension methods on Point #1585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, apart from these few nitpicks for consistency and to keep things concise.
Nice catch on the redundant imports @JaffaKetchup ! First I started by removing the For that reason I've updated the imports to: import 'dart:math' as math hide Point;
import 'dart:math' show Point; WDYT? |
It's less than ideal, I'm sure you'll agree, but OK for now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM I think. Would like another review though, if anyone can do it today!
02bf67b
to
3471c44
Compare
The CustomPoint class predates dart extension methods. The name is confusing (custom in what sense, and why) and in looking at the implementation it became clear that it was essentially just adding extension methods. Changing to a Point will avoid conversions in plugins which deal with libraries that use Point. Code will work as-is without changes with the exception of the subtraction operator. Previously CustomPoint<int> - CustomPoint<double> did not trigger analyzer warnings but would cause a runtime exception. This is now replaced by subtract() extension methods which allow subtracting num from a Point<double> and int from Point<int>.
Co-authored-by: 6y <tlserver6y@gmail.com>
3471c44
to
c1545dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
The CustomPoint class predates dart extension methods. The name is confusing (custom in what sense, and why) and in looking at the implementation it became clear that it was essentially just adding extension methods.
Changing to a Point will avoid conversions in plugins which deal with libraries that use Point.
Code will work as-is without changes with the exception of the subtraction operator. Previously CustomPoint - CustomPoint did not trigger analyzer warnings but would cause a runtime exception. This is now replaced by subtract() extension methods which allow subtracting num from a Point and int from Point.
Issue #1522 prompted me to look at this and I believe it resolves that issue (we no longer add methods which are not runtime-safe to Point and Point already documents the potential runtime error with the * operator).
Note that the vast majority of changes are just renaming CustomPoint to Point and importing it.