fromString static method

Bit fromString(
  1. String value
)

Creates a Bit from a string representation.

Implementation

static Bit fromString(String value) {
  if (value.isEmpty || !RegExp(r'^[01]+$').hasMatch(value)) {
    throw FormatException('Invalid bit string: $value');
  }
  return Bit(value.split('').map((c) => c == '1').toList());
}