Skip to content

fix: change _controller from a getter to a late field initialized during registration and add a scope registration check.#631

Open
dreyes17 wants to merge 1 commit intoSimformSolutionsPvtLtd:masterfrom
dreyes17:master
Open

fix: change _controller from a getter to a late field initialized during registration and add a scope registration check.#631
dreyes17 wants to merge 1 commit intoSimformSolutionsPvtLtd:masterfrom
dreyes17:master

Conversation

@dreyes17
Copy link

@dreyes17 dreyes17 commented Feb 3, 2026

Description

The issue was caused by race conditions during widget rebuilds or scope transitions where the ShowcaseService state was temporarily out of sync with the Showcase widget.

showcase.dart

Local Controller Caching

  • Converted _controller to a local late variable.
  • Initialized it in initState.
  • Updated it in didUpdateWidget and _updateControllerValues only when necessary.
  • This ensures the controller is always available to the widget without relying on potentially failing service lookups.

Scope Registration Safety

  • Added a guard clause in _updateControllerValues to check
    ShowcaseService.instance.isRegistered(scope: _scopeName)
    before calling getScope.
  • This prevents exceptions when the scope is temporarily unavailable during updates.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Fix #597 : The error is very difficult to reproduce so I am still checking with the Crashlytics if any similar error may still arise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'controller != null' error

1 participant