Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog shows up in Widgetbook instead of the simulated device #172

Closed
jttuboi opened this issue Apr 29, 2022 · 2 comments · Fixed by #197
Closed

Dialog shows up in Widgetbook instead of the simulated device #172

jttuboi opened this issue Apr 29, 2022 · 2 comments · Fixed by #197
Assignees
Labels
t: bug Something isn't working

Comments

@jttuboi
Copy link

jttuboi commented Apr 29, 2022

Description
Executing Widgetbook in web flutter, you want to simulate a Dialog inside the device, and it's showing inside of web page.
Check the screenshot for more detail.

Steps To Reproduce

WidgetbookCategory(name: 'asd1', widgets: [
    WidgetbookComponent(
      name: 'asd2',
      useCases: [
        WidgetbookUseCase(
          name: 'asd3',
          builder: (context) {
            return ElevatedButton(
              onPressed: () => showDialog(
                context: context,
                builder: (_) => AlertDialog(
                  content: Container(color: Colors.amber, height: 100, width: 100),
                ),
              ),
              child: const Text('show'),
            );
          },
        )
      ],
    ),
  ]),

Expected Behavior
I expect the Dialog is showed inside the device.

Screenshots
Untitled

@jenshor jenshor changed the title Dialog showed the web page, but not in the simulate device Dialog shows up in Widgetbook instead of the simulated device May 27, 2022
@jenshor jenshor self-assigned this May 27, 2022
@jenshor jenshor added the t: bug Something isn't working label May 27, 2022
@jenshor
Copy link
Member

jenshor commented May 27, 2022

In addition to the fix you also have to make sure to set the useRootNavigator to false, otherwise the showDialog will look for the root Navigator (which is the one of Widgetbook and not the one of the previewed app) and you'll see the same behaviour.

@tieorange
Copy link

This solution does not work with bottom sheet

It still is drawn outside of the device frame

Code:
final result = await showModalBottomSheet( isScrollControlled: true, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(15)), ), barrierColor: kcBottomSheetBarrierColor, backgroundColor: kcWayfinderWhite, context: context, useRootNavigator: false, builder: (context) => child, );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants