formatterKMile static method

String formatterKMile(
  1. int? startK,
  2. int? startMile,
  3. int? endk,
  4. int? endMile,
)

Implementation

static String formatterKMile(int? startK, int? startMile, int? endk, int? endMile) {
  String startKMile = "";
  if(startK != null && startK >= 0) {
    // startKMile = "K"+"${startK}".padLeft(3, "0");
    startKMile = "K" + "${startK}";
  }
  if(startMile != null && startMile >= 0) {
    startKMile += (startKMile.isNotEmpty ? ("+") : "") + "${startMile}".padLeft(3, "0");
  }

  String endKMile = "";
  if(endk != null && endk >= 0) {
    // endKMile = "K"+"${endk}".padLeft(3, "0");
    endKMile = "K" + "${endk}";
  }
  if(endMile != null && endMile >= 0) {
    endKMile += (endKMile.isNotEmpty ? ("+") : "") + "${endMile}".padLeft(3, "0");
  }

  if(startKMile.isEmpty) {
    return endKMile;
  } else {
    return startKMile + "-" + endKMile;
  }
}