position.dart 801 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. class Position {
  2. const Position(this.x, this.y);
  3. final int x;
  4. final int y;
  5. bool isBefore(Position another) {
  6. if (another == null) {
  7. return false;
  8. }
  9. return another.y > y || (another.y == y && another.x > x);
  10. }
  11. bool isAfter(Position another) {
  12. if (another == null) {
  13. return false;
  14. }
  15. return another.y < y || (another.y == y && another.x < x);
  16. }
  17. bool isBeforeOrSame(Position another) {
  18. if (another == null) {
  19. return false;
  20. }
  21. return another.y > y || (another.y == y && another.x >= x);
  22. }
  23. bool isAfterOrSame(Position another) {
  24. if (another == null) {
  25. return false;
  26. }
  27. return another.y < y || (another.y == y && another.x <= x);
  28. }
  29. @override
  30. String toString() {
  31. return 'MouseOffset($x, $y)';
  32. }
  33. }