decode method

  1. @override
List<String> decode(
  1. Input input
)
override

Implementation

@override
List<String> decode(Input input) {
  assertion(bitLength % 8 == 0, 'bitLength should be multiple of 8.');
  assertion(bitLength > 0, 'bitLength should be greater than 0.');
  assertion(bitLength <= 256, 'bitLength should be less than 256.');

  final codec = PrimitivesEnum.fromString('U$bitLength');
  final setIndex = codec.decode(input);
  final value = <String>[];

  /// Simplify above code with dart's bit operation
  if (setIndex > 0) {
    for (var index = 0; index < values.length; index++) {
      final item = values[index];
      if ((setIndex & (1 << index)) > 0) {
        value.add(item);
      }
    }
  }

  return value;
}