formatStringToUUID function

String formatStringToUUID(
  1. String value
)

Implementation

String formatStringToUUID(String value) {
  var res = "";

  value = value.replaceAll("-", "");

  if (value.length <= 36) {
    for (var i = value.length; i < 36; i++) {
      value = "${value}0";
    }
  } else {
    value = value.substring(0, 36);
  }

  res = value.substring(0, 8) +
      "-" +
      value.substring(8, 12) +
      "-" +
      value.substring(16, 20) +
      "-" +
      value.substring(20, 24) +
      "-" +
      value.substring(24, value.length);

  return res;
}