elements property

List<MusicalElement> elements
final

All musical elements in this measure, in order.

The list itself is mutable on purpose: importers append to it directly so they can build a bar that is momentarily incomplete (a <backup> in MusicXML rewinds the cursor, a malformed file may overfill a bar). That also means writing here bypasses the capacity check in add — which is exactly what the package's own parsers do.

Use add when you are authoring music and want the bar validated; write to elements only when you are reconstructing one from an external source and will validate it yourself (see MeasureValidator).

Implementation

final List<MusicalElement> elements = [];