shortenUUID static method
Takes a UUID, strips the dashes, and translates.
Strips longId
of dashes and passes it to the translator
function to be
converted into shortened form and returns the result.
Adds padding in front of the resulting short form if paddingParams
has
consistentLength
set to true.
Implementation
static String shortenUUID(String longId, Translator translator,
[PaddingParams? paddingParams]) {
final translated = translator(longId.toLowerCase().replaceAll('-', ''));
if (paddingParams == null || !paddingParams.consistentLength)
return translated;
return translated.padLeft(
paddingParams.shortIdLength,
paddingParams.paddingChar,
);
}