startConversion abstract method

  1. @protected
BinaryConversion startConversion()

Called when the conversion of a new object is started.

This method should return the first conversion to run incoming bytes into.

Once that first conversion produces a value, currentConversion should be set to the next conversion to run incoming bytes into, and this repeats until the last conversion needed to produce a value is created.

Once the final conversion produces a value, subclasses should call onValue with the value computed from the sub-conversions, and this conversion's state will be reset.

In practice, this method often is implemented as a series of nested onValue callbacks for the sub-conversions that capture the produced values as local variables:

@override
BinaryConversion startConversion() {
  return uint8.startConversion((firstValue) {
    currentConversion = utf8String.startConversion((secondValue) {
      currentConversion = BoolType().startConversion((thirdValue) {
        onValue((firstValue, secondValue, thirdValue));
      });
    });
  });
}

Implementation

@protected
BinaryConversion startConversion();