jamesblasco / modal_bottom_sheet

Flutter | Create advanced modal bottom sheets. Material, Cupertino or your own style
https://pub.dev/packages/modal_bottom_sheet
MIT License
1.85k stars 464 forks source link

Center sheet disappears in visual sheet stack #289

Open cmkramer opened 1 year ago

cmkramer commented 1 year ago

I've setup a CupertinoScaffolded screen and push a showCupertinoModalBottomSheet to show my first modal. I put the contents of that modal in a CupertinoScaffold. Then open a second modal sheet on top of it, also placed within a CupertinoScaffold. Here I get the following resulting animation glitch:

Double route visual glitch

So the structure is as follows:

CupertinoScaffold(body: SomeWidget) -> CupertinoScaffold.showCupertinoModalBottomSheet(CupertinoScaffold(body: SomeWidget)) -> CupertinoScaffold.showCupertinoModalBottomSheet(CupertinoScaffold(body: SomeWidget))

I'm trying to figure out what's happening here. I can see in the animation that the stack consists of only 2 sheets, while it should be 3, the animation glitch seems to be happening on the "in between" sheet, so I'm missing that one in the visual stack. This looks like a bug of sorts, but I can't wrap my head around what exactly is causing this.

When I change this structure to:

CupertinoScaffold(body: SomeWidget) -> CupertinoScaffold.showCupertinoModalBottomSheet(SomeWidget) -> CupertinoScaffold.showCupertinoModalBottomSheet(CupertinoScaffold(body: SomeWidget))

I get an "Unhandled Exception: Null check operator used on a null value" on CupertinoScaffold.of(context)!.topRadius; (cupertino_bottom_sheet.dart: 357).

Is there someone with an idea on what's happening here and how it can be resolved?

mark8044 commented 1 year ago

The answer is that you should use showCupertinoModalBottomSheet(...) instead of CupertinoScaffold.showCupertinoModalBottomSheet(...)