emitPoint method
Implementation
TrackPoint emitPoint({
required double latitude,
required double longitude,
bool accepted = true,
}) {
final track = _currentTrack;
if (track == null || track.status != TrackStatus.active) {
throw StateError('Start or resume a fake route before emitting points.');
}
final values = _points.putIfAbsent(track.id, () => <TrackPoint>[]);
final now = _clock().toUtc();
final point = TrackPoint(
id: 'fake-point-${values.length + 1}',
trackId: track.id,
segmentId: track.currentSegmentId!,
sequence: values.length + 1,
latitude: latitude,
longitude: longitude,
capturedAt: now,
persistedAt: now,
activityType: _activity.type,
activityConfidence: _activity.confidence,
motionState: MotionState.moving,
isMocked: false,
mockDetectionAvailable: true,
accepted: accepted,
qualityFlags: TrackPointQualityFlag.none,
);
values.add(point);
_tracks[track.id] = _copyTrack(
track,
acceptedPointCount: track.acceptedPointCount + (accepted ? 1 : 0),
rejectedPointCount: track.rejectedPointCount + (accepted ? 0 : 1),
nextSequence: point.sequence + 1,
lastPointAt: now,
);
_pointStream.add(point);
_publish();
return point;
}