Closed SpaceWaffles closed 2 years ago
@SpaceWaffles Thank for liking the package,
The following setup should work for you.
const marketTap = AutoRoute(
name: 'MarketTab',
page: EmptyRouterPage,
children: [
// assuming this is the page that will launch the bottom sheet
// inside of MarketPage simply call
// context.pushRoute(BottomSheetRouter());
AutoRoute(page: MarketPage, initial: true),
CustomRoute(
name: 'BottomSheetRouter',
page: EmptyRouterPage,
customRouteBuilder: modalSheetBuilder,
children: [
AutoRoute(page: Coin1Route ,initial: true),
AutoRoute(page, Coin1Route,)
]),
],
);
Route<T> modalSheetBuilder<T>(BuildContext context, Widget child, CustomPage<T> page) {
return ModalBottomSheetRoute(
settings: page,
builder: (context) => child,
expanded: true,
);
}
@Milad-Akarie Where do you get the ModalBottomSheetRoute
component? It does not seem to be defined in the auto_route
library.
Error message:
The function 'ModalBottomSheetRoute' isn't defined.
@pontus-andersson It's from the modal bottom sheet package mentioned above
This worked, thanks very much for the response!
@Milad-Akarie sorry for bringing this back, but I tried this approach and although it worked, I couldn't figure out how to make the bottom sheet not expand to full height. This: Navigator.of(context).push(ModalBottomSheetRoute(builder: (context) => Material(child: LoginScreen()), expanded: false))
seems to work correctly, while modalSheetBuilder (with expanded: false) does not.
P.S.: Great lib, btw! <3
I'm also seeing this behavior. The bottom sheet refuses to "wrap" the content. Unsure how to fix this.
just temporary solution for me with the expand, just specify the "containerBuilder"
set the/custom height ModalBottomSheetRoute( settings: page, containerBuilder: (context, animation, child) => SizedBox(height: 500, child: child), builder: (context) => child, expanded: false);
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions
Did somebody find a solution that does not involve setting a fixed height?
Hello, I'm trying to replicate whats @SpaceWaffles has done but I'm missing something... Can someone or @Milad-Akarie post a very simple example where:
Thanks! Marco
@pontus-andersson It's from the modal bottom sheet package mentioned above
what if we don't want to use that package? for eg : with showModalBottomSheet , is there any way?
Did somebody find a solution that does not involve setting a fixed height?
According to this issue, AutoRouter()
will always expand to fill its parent. To make it wrap its contents, put it inside an IntrinsicHeight
:
child: IntrinsicHeight(child: AutoRouter())
How to push modal bottom sheet as an auto route #1292
did you find any solution?
If you don't want to use extra dependencies like the modal_bottom_sheet
package, check this gist.
Also contains some helpers to get the scroll controller inside the modal content to take profit of DraggableScrollableSheet
easily.
Hi @emri99 thanks for your workaround.
I'm currently facing issue about bottom sheet display, it display in front of a newly pushed blank page. Are you experiencing the same issue?
Hello, thanks for this great library. I'm enjoying it but am stuck with this:
I'd like to have a flow sitting inside of a bottom sheet. I'm using this library: https://github.com/jamesblasco/modal_bottom_sheet which essentially improves on the basic
showBottomSheet
method.I'm having a hard time figuring out how to set up my nested routes and also am unsure how to navigate to this bottom sheet.
I am using the
AutoTabsScaffold
and on one of my tabs I'd like to be able to open a bottom sheet and then navigate around within this sheet.Here's my route setup for the tab in question:
Notice I'm using
CustomModalRoute
which is aCustomRoute
and my attempt to create a bottom sheet which I can navigate to.Here is that class:
When I try to open the sheet from within this tab by calling
context.pushRoute(BottomRoute(children: [Coin1Route()]));
I get
Unhandled Exception: [MarketTab Router] Router can not navigate to bottom-sheet/coin1
If I change
CustomModalRoute
to a regularAutoRoute
and try to navigate there by opening a bottom sheet like this:I get
So my questions are: How should I be setting up my nested routes and what is the correct way to launch a bottom sheet which displays a nested route?
Thank you!