Replace CustomPoint with extension methods on Point#1585
Conversation
JaffaKetchup
left a comment
There was a problem hiding this comment.
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! |
JaffaKetchup
left a comment
There was a problem hiding this comment.
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
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.