isPointOnLine function
Checks if a point lies on a line segment defined by two other points, considering a tolerance for line width.
Implementation
bool isPointOnLine(LatLng pointA, LatLng pointB, LatLng pointToCheck,
{double strokeWidth = 1.0}) {
// Calculate distances between points.
final distanceAToB = differenceInMeters(pointA, pointB);
final distanceAToX = differenceInMeters(pointA, pointToCheck);
final distanceBToX = differenceInMeters(pointB, pointToCheck);
// Calculate total distance along line segment.
final distance = distanceAToX + distanceBToX - distanceAToB;
// Check if point is within the line width tolerance.
return distance <= strokeWidth;
}