fromBinary static method

List<int> fromBinary(
  1. String data, {
  2. int zeroPadByteLen = 0,
})

Converts a binary string to a list of bytes.

Parses a binary string and converts it back to a list of bytes. An optional parameter allows padding the result with zeros to achieve a specific byte length.

Implementation

static List<int> fromBinary(String data, {int zeroPadByteLen = 0}) {
  BigInt intValue = BigInt.parse(data, radix: 2);
  String hexValue = intValue.toRadixString(16).padLeft(zeroPadByteLen, '0');
  return fromHexString(hexValue);
}