Skip to content

[Dart] Enums with "bit_flags" cannot be used as bit flags #9087

@jakobkordez

Description

@jakobkordez

Reading a bit_flags enum where multiple values are set throws an exception:

Unhandled exception:
RangeError (byteOffset): Index out of range: no indices are valid: 3
#0      _byteDataByteOffsetCheck (dart:typed_data-patch/typed_data_patch.dart:5419:5)
#1      _ByteDataView.getUint32 (dart:typed_data-patch/typed_data_patch.dart:5191:5)
#2      BufferContext._getUint32 (package:flat_buffers/flat_buffers.dart:68:41)
#3      BufferContext.derefObject (package:flat_buffers/flat_buffers.dart:40:43)
#4      TableReader.read (package:flat_buffers/flat_buffers.dart:1119:29)
...

Schema:

enum DigitalInputs: ubyte (bit_flags) {
    DI_CLK1,
    DI_CLK2,
    DI_S1,
    DI_S2,
}

table Holder {
    digital_inputs: DigitalInputs;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions