unpack property

List<String> unpack

Returns code required to unpack this field.

Implementation

List<String> get unpack {
    return <String>[
        if (optional) r'if ($getFlag()) {',
            if (!array) '$name = $_unpack;'
            else ...<String>[
                '$name = <$_type>[];',
                'final int ${name}Length = \$unpackUint32();',
                'for (int i = 0; i < ${name}Length; i++) {',
                    '$_name.add($_unpack);',
                '}',
            ],
        if (optional) '}',
    ];
}