Closed developer-medan closed 3 months ago
Hi, @developer-medan 👋
Currently, when the modal is visible, it is not straightforward to update the barrierDismissible
feature. However, I think this might work and let me know if it does:
WoltModalSheet.show(
context: context,
modalDecorator: (child) {
// Wrap the modal with `ChangeNotifierProvider` to manage the state of
// the entire modal. You can use any state management solution that you like.
return ChangeNotifierProvider<MyViewModel>(
builder: (_, __) => MyViewModel(),
child: child,
);
},
modalTypeBuilder: (context) {
// here you watch for the view model changes. When the state updates because the
// isTokenExpired value changes, it will rebuild the modal.
bool isTokenExpired = context.watch<MyViewModel>().state.isTokenExpired;
return WoltModalType.bottomSheet().copyWith(barrierDismissible: isTokenExpired),
}
);
I make app that open this modal. page are consist pageUpdateProfile, pageSetting (barrierDismissible = true). Sometime when page expired token, i push new page called pageExpiredToken in this modal, i want user cannot hide by tap barrier. the only way to dismissible is by tap button close in the page in this modal, so i need to update barrierDismissible = false. but if token is not expired while other page is opened, this barrierDismissible is true. is this feature exist?