diff --git a/lib/anybase_converter.dart b/lib/anybase_converter.dart index ecb6bd0..002fda3 100644 --- a/lib/anybase_converter.dart +++ b/lib/anybase_converter.dart @@ -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; @@ -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; diff --git a/lib/shortuuid.dart b/lib/shortuuid.dart index a204bc4..b524dae 100644 --- a/lib/shortuuid.dart +++ b/lib/shortuuid.dart @@ -10,8 +10,8 @@ class ShortUuid { "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#\$%&'()*+-./:<=>?@[]^_`{|}~"; static String shortv4( - {Map options, - String uuidv4 = null, + {Map? options, + String? uuidv4, String toAlphabet = flickrBase58}) { uuidv4 = uuidv4 == null ? Uuid().v4(options: options) : uuidv4; @@ -26,7 +26,7 @@ class ShortUuid { srcAlphabet: toAlphabet, dstAlphabet: AnyBaseConverter.HEX); String strUuidv4 = toHex.convert(shortUuid); var leftPad = ''; - var m = List(); + var m = []; for (var i = 0, len = 32 - strUuidv4.length; i < len; ++i) { leftPad += '0'; @@ -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('-'); diff --git a/pubspec.lock b/pubspec.lock index 71cabcc..e327263 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,356 +7,328 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "38.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.39.10" + version: "3.4.1" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" + version: "2.3.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.9.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.3.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.16.0" convert: dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "3.0.1" coverage: dependency: transitive description: name: coverage url: "https://pub.dartlang.org" source: hosted - version: "0.14.0" + version: "1.2.0" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" - csslib: - dependency: transitive - description: - name: csslib - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" - glob: + version: "3.0.1" + file: dependency: transitive description: - name: glob + name: file url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - html: + version: "6.1.2" + frontend_server_client: dependency: transitive description: - name: html + name: frontend_server_client url: "https://pub.dartlang.org" source: hosted - version: "0.14.0+3" - http: + version: "2.1.2" + glob: dependency: transitive description: - name: http + name: glob url: "https://pub.dartlang.org" source: hosted - version: "0.12.1" + version: "2.0.2" http_multi_server: dependency: transitive description: name: http_multi_server url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "3.2.0" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" + version: "4.0.0" io: dependency: transitive description: name: io url: "https://pub.dartlang.org" source: hosted - version: "0.3.4" + version: "1.0.3" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.2" + version: "0.6.4" logging: dependency: transitive description: name: logging url: "https://pub.dartlang.org" source: hosted - version: "0.11.4" + version: "1.0.2" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.11" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.7.0" mime: dependency: transitive description: name: mime url: "https://pub.dartlang.org" source: hosted - version: "0.9.6+3" - node_interop: - dependency: transitive - description: - name: node_interop - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - node_io: - dependency: transitive - description: - name: node_io - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" + version: "1.0.1" node_preamble: dependency: transitive description: name: node_preamble url: "https://pub.dartlang.org" source: hosted - version: "1.4.12" + version: "2.0.1" package_config: dependency: transitive description: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "2.0.2" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" + version: "1.8.1" pool: dependency: transitive description: name: pool url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.5.0" pub_semver: dependency: transitive description: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "1.4.4" + version: "2.1.1" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "0.7.7" + version: "1.3.0" shelf_packages_handler: dependency: transitive description: name: shelf_packages_handler url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "3.0.0" shelf_static: dependency: transitive description: name: shelf_static url: "https://pub.dartlang.org" source: hosted - version: "0.2.8" + version: "1.1.0" shelf_web_socket: dependency: transitive description: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "0.2.3" + version: "1.0.1" source_map_stack_trace: dependency: transitive description: name: source_map_stack_trace url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" source_maps: dependency: transitive description: name: source_maps url: "https://pub.dartlang.org" source: hosted - version: "0.10.9" + version: "0.10.10" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test: dependency: "direct dev" description: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.15.1" + version: "1.20.2" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.4.9" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.9" + version: "0.4.11" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" uuid: dependency: "direct main" description: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "3.0.6" vm_service: dependency: transitive description: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "8.2.2" watcher: dependency: transitive description: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "0.9.7+15" + version: "1.0.1" web_socket_channel: dependency: transitive description: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.1.0" webkit_inspection_protocol: dependency: transitive description: name: webkit_inspection_protocol url: "https://pub.dartlang.org" source: hosted - version: "0.7.3" + version: "1.0.0" yaml: dependency: transitive description: name: yaml url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.1.0" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.16.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 9b8bc25..36e7d62 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,10 +6,10 @@ homepage: https://github.com/coolmate/shortuuid repository: https://github.com/coolmate/shortuuid environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: - uuid: ^2.1.0 + uuid: ^3.0.1 dev_dependencies: test: any \ No newline at end of file