toHexString static method
Converts a List of integers representing bytes, dataBytes
, into a
hexadecimal string.
The method uses the hex
library to encode the byte list into a
hexadecimal string. It allows customization of the string's case
(lowercase or uppercase) using the lowerCase
parameter, and an optional
prefix
string can be appended to the resulting hexadecimal string.
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
.
Implementation
static String toHexString(List<int> dataBytes,
{bool lowerCase = true, String? prefix}) {
final String toHex = hex.hex.encode(dataBytes, lowerCase: lowerCase);
return "${prefix ?? ''}$toHex";
}