boolCodec top-level property

SimpleCodec<bool> boolCodec
final

Implementation

final boolCodec = SimpleCodec<bool>(
  nodeLocalName: 'boolean',
  encodeValue: (value) => value ? '1' : '0',
  decodeValue: (text) {
    if (text != '0' && text != '1') {
      throw StateError(
          'The element <boolean> must contain 0 or 1. Not "$text"');
    }
    return text == '1';
  },
);