tryFromHexString static method

BuBytes? tryFromHexString(
  1. String? data, {
  2. bool paddingZero = false,
})

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

Implementation

static BuBytes? tryFromHexString(String? data, {bool paddingZero = false}) {
  if (data == null) return null;
  try {
    return fromHexString(data, paddingZero: paddingZero);
  } catch (e) {
    return null;
  }
}