fix: guard repaint boundary keys via per-instance attach/detach #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
problem
repaintBoundaryKeyacross multipleScribblewidgets causedMultiple widgets used the same GlobalKeywhen go_router kept two/notes/:noteId/editpages alive viaMaterialPage(maintainState: true, key: state.pageKey)(see it-contest repo, branch design/clean-dev-xodnd @f13a67f / dev @38f056b).how i solved
Scribbleto aStatefulWidget, giving each instance its own_localRepaintBoundaryKeyand hooking the notifier through newattachRepaintBoundaryKey/detachRepaintBoundaryKeylifecycle methods.ScribbleNotifier.renderImagewhenever the legacy fallback key is used so integrators are nudged to adopt the new lifecycle before the fallback disappears.how it works
ScribbleNotifiertracks the attached keys and falls back to the legacy key so existing code keeps working;renderImagenow resolves to the most recently attached surface, which matches the single-canvas-per-notifier contract.verification
https://github.com/timcreatedit/scribbleref: maintohttps://github.com/ehdnd/scribbleref: fix/globalkey-collisioninsidehttps://github.com/tryCatchPing/it-contest(branches design/clean-dev-xodnd @f13a67f / dev @38f056b). RestoredMaterialPage(maintainState: true)—which previously forced us to fallback tofalse—and confirmed linked-note navigation (link tap, backlinks panel, note list) no longer emits the GlobalKey assertion.flutter testpasses on Flutter 3.32.5 (FVM). The new widget test (Scribble does not throw when sharing a notifier across multiple instances) fails against pre-fix sources, confirming regression coverage.note for integrators
ScribbleNotifierBaseimplementations must overrideattachRepaintBoundaryKey/detachRepaintBoundaryKeyto keeprenderImageworking; consider this a behavior change for external notifiers.Checklist