showSideSheet static method

dynamic showSideSheet({
  1. required BuildContext context,
  2. Widget builder(
    1. BuildContext
    )?,
  3. bool rightSide = true,
  4. Duration animationDuration = const Duration(milliseconds: 300),
  5. double width = 300,
})

Implementation

static showSideSheet({
  required BuildContext context,
  Widget Function(BuildContext)? builder,
  bool rightSide = true,
  Duration animationDuration = const Duration(milliseconds: 300),
  double width = 300,
}) {
  showGeneralDialog(
    barrierLabel: "dive_side_sheet",
    barrierDismissible: true,
    barrierColor: Colors.black.withOpacity(0.5),
    transitionDuration: animationDuration,
    context: context,
    pageBuilder: (context, animation1, animation2) {
      return Align(
        alignment: (rightSide ? Alignment.centerRight : Alignment.centerLeft),
        child: Container(
          child: builder!(context),
          height: double.infinity,
          width: width,
          decoration: BoxDecoration(
            color: Colors.white,
          ),
        ),
      );
    },
    transitionBuilder: (context, animation1, animation2, child) {
      return SlideTransition(
        position:
            Tween(begin: Offset((rightSide ? 1 : -1), 0), end: Offset(0, 0))
                .animate(animation1),
        child: child,
      );
    },
  );
}