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(
argument: ManageSelectArgument(
iban: widget.argument.iban,
cashBalance: widget.argument.cashBalance,
digitalDepotAccountId: widget.argument.digitalDepotAccountId,
withdrawBalance: widget.argument.withdrawBalance,
canWithdraw: widget.argument.canWithdraw,
isPaused: widget.argument.isPaused,
),
),
).then((_) => _getSavingsPlanDetail(context));
Can we check the modal bottom sheet is closed by drag down or by Navigator.pop
?
Because I have a condition when the modal is closed by Navigator.pop
want to execute API function (_getSavingsPlanDetail
), but if by drag down is not.
Because for now the _getSavingsPlanDetail
is always executed.
To create a modal bottom sheet, I use this package: https://pub.dev/packages/modal_bottom_sheet
you can try in this way
bool? b = 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(
argument: ManageSelectArgument(
iban: widget.argument.iban,
cashBalance: widget.argument.cashBalance,
digitalDepotAccountId: widget.argument.digitalDepotAccountId,
withdrawBalance: widget.argument.withdrawBalance,
canWithdraw: widget.argument.canWithdraw,
isPaused: widget.argument.isPaused,
),
),
);
if(b == true){
// came from Navigator.pop
// can do anything
_getSavingsPlanDetail(context));
}else{
// came from other way
}
Note: use
Navigator.pop(context, true);
instate ofNavigator.pop(context);