Files
companion/lib/domain/models/position.dart
T
2026-05-07 18:35:58 +02:00

26 lines
725 B
Dart

// Normalised coordinates: x and y are in the range 0..1 relative to the floor plan canvas.
class Position {
const Position({required this.x, required this.y});
final double x;
final double y;
Position copyWith({double? x, double? y}) =>
Position(x: x ?? this.x, y: y ?? this.y);
// Key names should match localiserd API fields.
Map<String, dynamic> toJson() => {'x': x, 'y': y};
factory Position.fromJson(Map<String, dynamic> json) => Position(
x: (json['x'] as num).toDouble(),
y: (json['y'] as num).toDouble(),
);
@override
bool operator ==(Object other) =>
other is Position && other.x == x && other.y == y;
@override
int get hashCode => Object.hash(x, y);
}