Drawing a track - two mistakes that silently ruin the render
01 Sept 2026 · Field Track 360
``` final track = await TrackIt.instance.buildTrack( query: PointQuery(sessionId: id), );
// Precision 6, NOT the 5 most decoders assume. Read it off the track. final line = decodePolyline(track.encodedPolyline, precision: track.precision);
for (final s in track.segments.where((s) => s.isTravel)) { draw(decodePolyline(s.encodedPolyline, precision: track.precision), color(s.speedBand)); }
for (final stop in track.stops) marker(stop.position, stop.dwell, pulse: stop.isOngoing); for (final a in track.arrows) arrow(a.position, rotation: a.bearing); ```
Why decodePolyline ships in this package
TrackIt encodes at precision 6 and the common decoders default to 5. That does not fail - it returns coordinates ten times too small and plots the track into the sea.
speedBand: green is the fastest
The names follow the traffic-map convention, so green is the fastest band and red the slowest. Colouring green as "slow" inverts every drawn track.
Live tracking: check the sequence
``` TrackIt.instance.liveTrack.listen((frame) { if (frame.sequence <= lastDrawn) return; // REQUIRED lastDrawn = frame.sequence; }); ```
Frames can arrive out of order across a dispatcher hop and a platform channel; drawing a stale one makes the puck jump backwards. Never re-smooth frozenTailPolyline - it is already smoothed. And puck.headingDeg is null when velocity is too small to have a direction: hold your last rotation rather than snapping to a fabricated 0 degrees.