tomoyu719 / simple_sheet_music

A Flutter package for rendering sheet music.
https://pub.dev/packages/simple_sheet_music
MIT License
10 stars 6 forks source link

Rendering error when building chords of NoteDuration.whole #12

Closed heyaphra closed 4 months ago

heyaphra commented 4 months ago

Hi, thanks for implementing chords!

I ran across the following error preventing the rendering of whole note chords - you should be able to reproduce the issue by trying to create a ChordNote with noteDuration set to NoteDuration.whole.

Exception caught:

════════ Exception caught by rendering library ═════════════════════════════════
The following NoSuchMethodError was thrown during paint():
The method '[]' was called on null.
Receiver: null
Tried calling: []("stemUpSE")

Truncated stack trace:

When the exception was thrown, this was the stack:
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
object_patch.dart:38
#1      GlyphMetadata.stemRootOffset (package:simple_sheet_music/src/glyph_metadata.dart:56:27)
glyph_metadata.dart:56
#2      ChordNoteMetrics._noteStemRootOffset (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:279:16)
chord_note.dart:279
#3      ChordNoteMetrics._uppestNoteStemRootOffset (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:242:43)
chord_note.dart:242
#4      ChordNoteMetrics._tipNoteStemRootToStaffCenterDist (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:251:9)
chord_note.dart:251
#5      ChordNoteMetrics._isStemCentered (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:256:7)
chord_note.dart:256
#6      ChordNoteMetrics.stemTipOffset (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:292:9)
chord_note.dart:292
#7      ChordNoteMetrics._top (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:182:9)
chord_note.dart:182
#8      ChordNoteMetrics._bbox (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:174:42)
chord_note.dart:174
#9      ChordNoteMetrics.width (package:simple_sheet_music/src/music_objects/notes/chord_note/chord_note.dart:209:46)
chord_note.dart:209
#10     MeasureMetrics.objectsWidth.<anonymous closure> (package:simple_sheet_music/src/measure/measure_metrics.dart:37:54)
measure_metrics.dart:37

...
...
...

The following RenderObject was being processed when the exception was fired: RenderCustomPaint#e2ba3 relayoutBoundary=up4
    parentData: <none> (can use size)
    constraints: BoxConstraints(0.0<=w<=175.0, 0.0<=h<=137.5)
    size: Size(175.0, 87.5)
    painter: SheetMusicRenderer#7c9ca()
    preferredSize: Size(175.0, 87.5)
RenderObject: RenderCustomPaint#e2ba3 relayoutBoundary=up4
    parentData: <none> (can use size)
    constraints: BoxConstraints(0.0<=w<=175.0, 0.0<=h<=137.5)
    size: Size(175.0, 87.5)
    painter: SheetMusicRenderer#7c9ca()
    preferredSize: Size(175.0, 87.5)
tomoyu719 commented 4 months ago

Thank you for your report. A corrected version 1.0.1 is now available on Pub.dev.