How to ignore click events on Slivers of CustomScrollView in Flutter?

574 Views Asked by At

I have a Stack widget as the body of the Scaffold and the stack has a CustomScrollView and some other widget behind the scroll view as its children.

Scaffold(
  body: Stack(
    children: [
      WidgetBehindTheScrollView(),
      CustomScrollView(
        slivers: [
          SliverAppBar(),
          SliverBelowTheAppBar(),
        ],
      ),
    ],
  ),
);

What I want to achieve is to make WidgetBehindTheScrollView clickable by making SliverBelowTheAppBar ignore the pointer events on occasion. But I don't want SliverAppBar to ignore pointer events. So I can't wrap the CustomScrollView with IgnorePointer.

I tried wrapping SliverBelowTheAppBar with SliverIgnorePointer but I still can't interact with the WidgetBehindTheScrollView.

1

There are 1 best solutions below

0
On

You can use combo widget Sliver:

     // ),
            SliverIgnorePointer(
              ignoring: true,
              ignoringSemantics: true,
              sliver: SliverToBoxAdapter(
                child: IgnorePointer(
                  child: Container(
                    color: Colors.green,
                    height: kSpaceBottom,
                    width: MediaQuery.of(context).size.width,
                  ),
                ),
              ),
            ),