showBottomSheet method

void showBottomSheet({
  1. required Widget child,
  2. required BuildContext context,
})

to show bottom sheet in different screens which requires child widget and context

Implementation

void showBottomSheet({required Widget child, required BuildContext context}) {
  showModalBottomSheet(
    backgroundColor: Colors.transparent,
    context: context,
    isScrollControlled: true,
    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0)),
    builder: (context) {
      return Padding(
        padding: EdgeInsets.only(
            bottom: MediaQuery.of(context).viewInsets.bottom,
            left: 10,
            right: 10,
            top: 10),
        child: Stack(
          children: [
            Center(
              child: GestureDetector(
                onTap: () {
                  Navigator.pop(context);
                },
              ),
            ),
            Center(
              child: child,
            ),
          ],
        ),
      );
    },
  );
}