Skip to content

fix: add listen: false to showToolbar() and hideToolbar()#280

Open
nateshmbhat wants to merge 1 commit into
aloisdeniel:masterfrom
nateshmbhat:fix/listen-false-minimal
Open

fix: add listen: false to showToolbar() and hideToolbar()#280
nateshmbhat wants to merge 1 commit into
aloisdeniel:masterfrom
nateshmbhat:fix/listen-false-minimal

Conversation

@nateshmbhat

Copy link
Copy Markdown

Description

Fixes #278

Adds listen: false parameter to Provider.of<DevicePreviewStore>() calls in showToolbar() and hideToolbar() methods to prevent assertion errors when called from event handlers.

Changes

Only two lines changed:

  • Line 245: Added , listen: false to showToolbar() method
  • Line 257: Added , listen: false to hideToolbar() method

Why This Fix is Needed

Without listen: false, calling these methods from event handlers (button onPressed, switch onChanged, etc.) throws:

Tried to listen to a value exposed with provider, from outside of the widget tree.
Failed assertion: 'context.owner!.debugBuilding || listen == false || debugIsInInheritedProviderUpdate'

Consistency

This makes both methods consistent with other static methods in the same file like selectDevice() and availableDeviceIdentifiers() which already use listen: false.

Testing

Verified with a switch widget calling these methods - no more errors:

Switch(
  value: isVisible,
  onChanged: (value) {
    value ? DevicePreview.showToolbar(context) : DevicePreview.hideToolbar(context);
  },
)

Fixes aloisdeniel#278

Added `listen: false` parameter to Provider.of calls in showToolbar()
and hideToolbar() methods to prevent assertion errors when called
from event handlers.
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.

showToolbar() and hideToolbar() methods missing listen: false causing assertion error when called from event handlers

1 participant