boolCodec top-level property

SimpleCodec<bool> boolCodec
final

Implementation

final boolCodec = SimpleCodec<bool>(
  nodeLocalName: 'boolean',
  encodeValue: (value) => switch (value) {
    false => '0',
    true => '1',
  },
  decodeValue: (text) => switch (text) {
    '0' => false,
    '1' => true,
    _ => throw StateError(
        'The element <boolean> must contain 0 or 1. Not "$text"'),
  },
);