Closed rrifafauzikomara closed 2 years ago
There is different ways to achieve this:
Via a callback method that you on the onPressed button after Navigator.pop
showCupertinoModalBottomSheet(
expand: true,
context: context,
backgroundColor: ColorPalettes.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
),
),
isDismissible: true,
builder: (rootContext) => ManageSavingsPlanSheet(
onClosedByUser: () {
_getSavingsPlanDetail(context);
},
/// more params
),
);
Return a value when tapping the button Navigator.pop(context, true)
final shouldShowSavings = await showCupertinoModalBottomSheet<bool>(
expand: true,
context: context,
backgroundColor: ColorPalettes.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
),
),
isDismissible: true,
builder: (rootContext) => ManageSavingsPlanSheet(
onClosedByUser: () {
Navigator.of(rootContext).pop(true);
},
/// more params
),
);
if(shouldShowSavings) _getSavingsPlanDetail(context);
Can we check the modal bottom sheet is closed by the user (drag) or by
Navigator.pop
(from a button inside the modal bottom sheet)?Because I have a condition when the modal is closed by
Navigator.pop
want to execute API function (_getSavingsPlanDetail
), but if by the user manually is not.Because for now the
_getSavingsPlanDetail
is always executed.