getAllLines static method

Future<List<RouteLine>> getAllLines({
  1. bool activeOnly = false,
})

Implementation

static Future<List<RouteLine>> getAllLines({bool activeOnly = false}) async {
  Uri url = Uri.parse("https://ws.tib.org/sictmws-rest/lines/ctmr4");
  try {
    Uint8List responseBytes =
        await httpClient.get(url).then((value) => value.bodyBytes);

    List<RouteLine> lines = [];
    for (Map line in json.decode(utf8.decode(responseBytes))["linesInfo"]) {
      if (activeOnly && line["act"] == false) {
        continue;
      }
      lines.add(RouteLine.fromJson(line));
    }

    return lines;
  } on FormatException {
    throw FormatException("Something went wrong.");
  }
}