tryToHexString static method
Tries to convert a list of integers representing bytes, dataBytes
, into a
hexadecimal string.
If dataBytes
is null, returns null. Otherwise, attempts to convert the
byte list into a hexadecimal string using the toHexString function.
If successful, returns the resulting hexadecimal string; otherwise, returns null.
Parameters:
dataBytes
: A List of integers representing bytes to be converted.lowerCase
: Whether the resulting hexadecimal string should be in lowercase (default is true).prefix
: An optional string to append as a prefix to the hexadecimal string.
Returns:
- A hexadecimal string representation of
dataBytes
, or null if conversion fails.
Implementation
static String? tryToHexString(List<int>? dataBytes,
{bool lowerCase = true, String? prefix}) {
if (dataBytes == null) return null;
try {
return toHexString(dataBytes, lowerCase: lowerCase, prefix: prefix);
} catch (e) {
return null;
}
}