followRoute static method
Stream<LatLng>
followRoute({
- required SmartRoute route,
- Duration stepDuration = const Duration(milliseconds: 1000),
- double speedKmph = 40.0,
Simulates movement along a route. Returns a stream of LatLng positions.
Implementation
static Stream<LatLng> followRoute({
required SmartRoute route,
Duration stepDuration = const Duration(milliseconds: 1000), // Smoothness
double speedKmph = 40.0, // Simulated speed if not using duration
}) async* {
if (route.points.isEmpty) return;
for (int i = 0; i < route.points.length - 1; i++) {
final start = route.points[i];
final end = route.points[i + 1];
yield start;
// Interpolate for smoothness
// Simple implementation: just yield points for now.
// Advanced: Calculate intermediate points based on speed.
await Future.delayed(stepDuration);
yield end;
}
}