Show SnackBar on modal inside modal

My condition is i have modal inside modal, using showModalBottomSheet, we can call it first modal then second modal. I want to show ScaffoldMessenger.of(context).showSnackBar on second modal, but when i trigger it, it appear only on first modal. Of course i use the context of second modal.

showModalBottomSheet(
    context: context,
    isScrollControlled: true,
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.all(Radius.circular(10)),
    ),
    clipBehavior: Clip.hardEdge,
    backgroundColor: Colors.transparent,
    builder: (_) => BlocProvider.value(
      value: BlocProvider.of<ShowPostBloc>(context),
      child: SecondModal(),
    ),
  );

ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Hallo')));

Can anyone explain it, why this is happen?

Use Scaffold() for first and second modal, SnackBar will appear on both modal.

Leave a Comment