buildInstructions method

Future<List<RoadInstruction>> buildInstructions(
  1. Road road, {
  2. Languages languages = Languages.en,
})

buildInstructions

this method to generate instructions of specific road

Implementation

Future<List<RoadInstruction>> buildInstructions(
  Road road, {
  Languages languages = Languages.en,
}) async {
  final legs = road.roadLegs;
  final instructionsHelper =
      await loadInstructionHelperJson(language: languages);
  final List<RoadInstruction> instructions = [];
  legs.asMap().forEach((indexLeg, listSteps) {
    for (var step in listSteps) {
      final instruction = buildInstruction(
        step,
        instructionsHelper,
        {
          "legIndex": indexLeg,
          "legCount": legs.length - 1,
        },
      );
      RoadInstruction roadInstruction = RoadInstruction(
        distance: step.distance,
        duration: step.duration,
        instruction: instruction,
        location: step.maneuver.location,
      );
      instructions.add(roadInstruction);
    }
  });
  return instructions;
}