26 lines
725 B
Dart
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);
|
|
}
|