tryDecodeParameter static method
Implementation
static Uint8List? tryDecodeParameter(
String value, {
Set<int>? allowedLengths,
}) {
try {
if (_hexPattern.hasMatch(value) && value.length.isEven) {
final decoded = Uint8List.fromList([
for (var i = 0; i < value.length; i += 2)
int.parse(value.substring(i, i + 2), radix: 16),
]);
if (allowedLengths == null || allowedLengths.contains(decoded.length)) {
return decoded;
}
}
final decoded =
Uint8List.fromList(base64Url.decode(base64Url.normalize(value)));
if (allowedLengths != null && !allowedLengths.contains(decoded.length)) {
return null;
}
return decoded;
} catch (_) {
return null;
}
}