2

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.

rasitayaz
  • 400
  • 2
  • 16
  • why would you want this behaviour? the scrollview is on the top to receive touch event for scrolling, if the underneath view is also clickable, the system will be confused if you want to scroll or click. – jaychang0917 Jul 26 '21 at 02:24
  • It's a little complicated, I have a search bar at the bottom of the AppBar and when I click the search bar, I want to display search results where the SliverBelowTheAppBar located. But I don't want the search results to be inside the ScrollView (to be a Sliver). So I placed it under the ScrollView using a Stack. – rasitayaz Jul 26 '21 at 08:50
  • why not placing the search results above the scrollview? – jaychang0917 Jul 26 '21 at 09:19
  • That's exactly what I tried first. But the AppBar has a shadow underneath and if I place the results above the ScrollView, then the shadow stays behind the results. – rasitayaz Jul 26 '21 at 09:30

1 Answers1

0

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,
                  ),
                ),
              ),
            ),