Open naamapps opened 6 months ago
Unfortunately, with the current version, adding invisible space around the sheet is a bit tricky. I hope the following steps will solve your problem:
SheetShape
.SafeArea
to out of the NavigationSheet
from the SheetShape
.
SafeArea(child: NavigationSheet(...));
Card
, ClipRRect
or something, not outside of the Navigator
, but inside each page.
ClipRRect(child: StaticSheetContent(...));
Here's a fork from the tutorial code of the NavigationSheet
, adding extra space around the sheet.
https://github.com/fujidaiti/smooth_sheets/assets/68946713/7b7bd8ee-b793-4d98-b5c1-25d525c95d95
I got a normal modal sheet working with invisible space around, it's just that the navigation sheet isn't working like the normal one.
Are you sure there isn't a bug regarding the navigation sheet? I also didn't succeed reproducing the example you wrote here.. Can you try pushing a new ModalSheetRoute with NavigationSheet instead of putting the sheet inside a Stack?
Also, your example transition from one sheet to the other is not really smooth because the transition not only for the content but rather for the whole sheet! - which is not the expected result I'm trying to achieve.
This is a working code with gaps all around the sheet (using the widgets I wrote above & without NavigationSheet):
final modalRoute = ModalSheetRoute<bool>(
transitionDuration: const Duration(milliseconds: 250),
builder: (context) => const SheetDismissible(
child: DraggableSheet(
child: StaticSheetContent(
header: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('hello'),
],
),
body: Padding(
padding: EdgeInsets.all(8.0),
child: Text('wow'),
),
footer: Text('hi'),
),
),
),
);
final result = await Navigator.push<bool>(context, modalRoute);
Are you sure there isn't a bug regarding the navigation sheet?
No. It's a limitation of the current version.
I got a normal modal sheet working with invisible space around
Although it seems to work in some configurations, adding invisible space around a sheet is not yet officially supported. For example, wrapping a SheetContentScaffold
with a SafeArea
won't work as we expected:
DraggableSheet(
child: SafeArea(
child: SheetContentScaffold(...),
),
);
Can you try pushing a new ModalSheetRoute with NavigationSheet instead of putting the sheet inside a Stack?
Try this:
class _ImperativeNavigationSheetExample extends StatelessWidget {
const _ImperativeNavigationSheetExample();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return Center(
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
ModalSheetRoute(
builder: (_) => const _ExampleSheet(),
),
);
},
child: const Text('Show Sheet'),
),
);
},
),
),
);
}
}
Just wanted to express my interest in this as well. Being able to have the padding around the sheet as well as the ability to navigate/animate the sheets themselves would align with my intended design language.
Hi, While pushing a new navigation modal sheet, it's not taking SafeArea and bottom margin into consideration. Code:
Expected - There should be a gap from the bottom of the screen:
Actual - The sheet is attached to the bottom of the screen: