widgetbook icon indicating copy to clipboard operation
widgetbook copied to clipboard

InspectorAddon color picker fails with assertion

Open bramp opened this issue 1 year ago • 4 comments

Description

When using the InspectorAddon, color picker the following assertion fails:

_AssertionError ('package:flutter/src/material/scaffold.dart': Failed assertion: line 295 pos 7: '_scaffolds.isNotEmpty': ScaffoldMessenger.showSnackBar was called, but there are currently no descendant Scaffolds to present to.)

Steps To Reproduce

  1. Create WidgetbookApp with the following:
Widget build(BuildContext context) => Widgetbook.material(
        directories: directories,
        addons: [
          InspectorAddon(enabled: true),
        ],
        integrations: const [],
      );
  1. Click the color picker button
  2. Select a color on your widget, and
  3. boom assertion.

Expected Behavior

It not crash.

Additional Context

The widget I'm testing does not make use of ScaffoldMessenger, so I suspect InspectorAddon assumes that is available higher up the widget stack.

bramp avatar Feb 28 '24 00:02 bramp

Hello @bramp 👋 There was a related fix (#1091) that was released in v3.7.1, make sure to update to the latest version. I will close the issue for now due to the potential fix, and re-open if this didn't fix your issue.

yousinix avatar Feb 28 '24 09:02 yousinix

Sorry I didn't mention my version. I was all up to date before posting this issue:

dependencies:
  widgetbook: ^3.7.1
  widgetbook_annotation: ^3.1.0

dev_dependencies:
  widgetbook_generator: ^3.7.0

So this looks to still be a issue.

bramp avatar Feb 28 '24 16:02 bramp

Putting a debugDumpApp(); inside showColorPickerResultSnackbar shows there is indeed no Scaffold above the widget, instead it seems to be Overlay/_OverlayEntryWidget widgets. Please reopen this bug, and investigate. Thanks.

bramp avatar Feb 28 '24 17:02 bramp

I faced this issue too. Possible workaround here

addons: [
  BuilderAddon(
    name: 'Scaffold',
    builder: (context, child) => Scaffold(
      body: child,
    ),
  ),
  InspectorAddon(),
],

ilia-korolev avatar Dec 03 '24 02:12 ilia-korolev