Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/anybase_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ class AnyBaseConverter {
AnyBaseConverter(
{this.srcAlphabet = AnyBaseConverter.DEC,
this.dstAlphabet = AnyBaseConverter.HEX}) {
if (srcAlphabet == null ||
dstAlphabet == null ||
(srcAlphabet != null && srcAlphabet.isEmpty) ||
(dstAlphabet != null && dstAlphabet.isEmpty)) {
if ((srcAlphabet.isEmpty) || (dstAlphabet.isEmpty)) {
throw Exception('Bad alphabet');
}
this.srcAlphabet = srcAlphabet;
Expand Down Expand Up @@ -68,7 +65,7 @@ class AnyBaseConverter {
}
}
length = newlen;
result = dstAlphabet.substring(divide, divide + 1) + result;
result = dstAlphabet.substring(divide, divide + 1) + result.toString();
} while (newlen != 0);

return result;
Expand Down
12 changes: 7 additions & 5 deletions lib/shortuuid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class ShortUuid {
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#\$%&'()*+-./:<=>?@[]^_`{|}~";

static String shortv4(
{Map<String, dynamic> options,
String uuidv4 = null,
{Map<String, dynamic>? options,
String? uuidv4,
String toAlphabet = flickrBase58}) {
uuidv4 = uuidv4 == null ? Uuid().v4(options: options) : uuidv4;

Expand All @@ -26,7 +26,7 @@ class ShortUuid {
srcAlphabet: toAlphabet, dstAlphabet: AnyBaseConverter.HEX);
String strUuidv4 = toHex.convert(shortUuid);
var leftPad = '';
var m = List<String>();
var m = <String>[];

for (var i = 0, len = 32 - strUuidv4.length; i < len; ++i) {
leftPad += '0';
Expand All @@ -38,8 +38,10 @@ class ShortUuid {
if (matches.isNotEmpty) {
var match = matches.first;
for (var i = 1; i <= match.groupCount; i++) {
var matchStr = match.group(i);
m.add(matchStr);
String? matchStr = match.group(i);
if (matchStr != null) {
m.add(matchStr);
}
}
}
return [m[0], m[1], m[2], m[3], m[4]].join('-');
Expand Down
Loading