tryToHexString static method

String? tryToHexString(
  1. List<int>? dataBytes, {
  2. bool lowerCase = true,
  3. String? prefix,
})

Like toHexString, but returns null instead of throwing on failure (or if dataBytes is null).

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;
  }
}