InspectorAddon color picker fails with assertion
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
- Create
WidgetbookAppwith the following:
Widget build(BuildContext context) => Widgetbook.material(
directories: directories,
addons: [
InspectorAddon(enabled: true),
],
integrations: const [],
);
- Click the color picker button
- Select a color on your widget, and
- 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.
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.
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.
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.
I faced this issue too. Possible workaround here
addons: [
BuilderAddon(
name: 'Scaffold',
builder: (context, child) => Scaffold(
body: child,
),
),
InspectorAddon(),
],