fujidaiti / smooth_sheets

Sheet widgets with smooth motion and great flexibility.
https://pub.dev/packages/smooth_sheets
MIT License
195 stars 19 forks source link

Is there a way to have a backdrop filter (blur) for the barrier instead of just a color? #208

Open mark8044 opened 1 month ago

mark8044 commented 1 month ago

Is there a way to have a backdrop filter (blur) for the barrier instead of just a color?

Ideally with animation as well (so the blur can come in and out). This is currently possible with Sheets/ModalBottomSheet package as we are given a builder to work with and would be a wonderful addition here

fujidaiti commented 1 month ago

Hi @mark8044,

Currently, there is no convenient way to add a custom modal barrier. However, you can extend ModalSheetRoute and override buildModalBarrier() to customize the barrier creation logic:

class CustomModalSheetRoute extends ModalSheetRoute {
  CustomModalSheetRoute({
    super.settings,
    super.fullscreenDialog,
    required super.builder,
    super.maintainState,
    super.barrierDismissible,
    super.barrierLabel,
    super.barrierColor,
    super.swipeDismissible,
    super.transitionDuration,
    super.transitionCurve,
  });

  @override
  Widget buildModalBarrier() {
    void onDismiss() {
      if (animation!.isCompleted && !navigator!.userGestureInProgress) {
        navigator?.maybePop();
      }
    }

    return CustomModalBarrier(
      onDismiss: onDismiss,
      ...
    );
  }
}