-
Notifications
You must be signed in to change notification settings - Fork 64
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
How to conditionally control modal closure (using Riverpod)? #342
Comments
Follow-up question related to Riverpod usage (sorry, out of scope for the original question, can create a new issue if needed) Example, page 1: Adding items, page 2: Deleting items UI updates are functional if used inside a normal showModalBottomSheet, so their logic should be sound. |
Hi There! ref.watch(provider) and context.watch means that you want to watch the entire modal content. Please create your provider using the WoltModalSheet.show(
context: context,
pageContentDecorator: (widget) => Align(
alignment: Alignment.bottomCenter,
child: ClipRRect(
..., // Your clipRRect properties
child: BackdropFilter(
..., // Your backdrop filter properties
child: widget,
),
),
),
modalDecorator: (child) {
// Wrap the modal with `ChangeNotifierProvider` to manage the state of
// the entire pages in the modal.
return ChangeNotifierProvider<StoreOnlineViewModel>(
builder: (_, __) => StoreOnlineViewModel(),
child: child,
);
},
pageListBuilder: (context) {
final viewModel = context.read<StoreOnlineViewModel>();
return [
WoltModalSheetPage(
child: FirstPageContent(viewModel.data),
pageTitle: Text('First Page Title'),
// Other properties...
),
WoltModalSheetPage(
child: SecondPageContent(viewModel.data),
pageTitle: Text('Second Page Title'),
// Other properties...
),
];
},
); When it comes to conditional displaying the content; please refer to this example: Screen.Recording.2024-11-15.at.13.29.18.mov |
Thanks for the response. You mentioned the use of |
Ups, I edited my answer. |
Question on how to correctly handle
enableDrag
,barrierDismissable
and system pop.Consider the following example:
WoltModalSheetPage
contains a counterenableDrag
,barrierDismissable
by disabling them.Below is an example of how I currently have
WoltModalSheet.show
setup. I was able to conditionally hide the trailing widget usingpageContentDecorator
, but have been unsuccessful withenableDrag
andbarrierDismissable
.Considering my current setup, what's the best way to conditionalize
enableDrag
andbarrierDismissable
?What is the best way to guard system pop (by displaying
_showDismissConfirmationDialog
)?The text was updated successfully, but these errors were encountered: