position.dart 629 B

12345678910111213141516171819202122232425262728293031323334
  1. import 'package:flutter/material.dart';
  2. import './path.dart';
  3. class Position {
  4. final Path path;
  5. final int offset;
  6. Position({
  7. required this.path,
  8. this.offset = 0,
  9. });
  10. @override
  11. bool operator ==(Object other) {
  12. if (other is! Position) {
  13. return false;
  14. }
  15. return pathEquals(path, other.path) && offset == other.offset;
  16. }
  17. @override
  18. int get hashCode {
  19. final pathHash = hashList(path);
  20. return Object.hash(pathHash, offset);
  21. }
  22. Position copyWith({Path? path, int? offset}) {
  23. return Position(
  24. path: path ?? this.path,
  25. offset: offset ?? this.offset,
  26. );
  27. }
  28. }