flip function

String flip(
  1. String binary
)

Implementation

String flip(String binary) {
  return binary.replaceAllMapped(
      RegExp('[01]'), (match) => match.group(0) == '1' ? '0' : '1');
}