can't scroll after adding a transparent container

Viewed 93

I have a PageView with Stack children. those Stack widgets contain transparent containers that controlls the opacity level relative to the scroll position.

the expense is that now I am unable to scroll what's in the background. what is the best way to add that layer and keep my backround scroll active.

Updating the Listview widget seems expensive as the opacity transion changes that is why I tried to keep it separate

I have something like this

Stack(children: [
                Scaffold(
                  body: SafeArea(
                    child: Container(
                      color: Colors.white,
                      child: ListView...,   // the listView I am trying to scroll
                    ),
                  ),
                ),
                currIndex == 1 ? MainCardTransitionContainer() : Container(), // the layer with opacity 
              ]),
2 Answers

Try IgnorePointer:

Stack(children: [
                Scaffold(
                  body: SafeArea(
                    child: Container(
                      color: Colors.white,
                      child: ListView...,   // the listView I am trying to scroll
                    ),
                  ),
                ),
                currIndex == 1 ? IgnorePointer(ignoring: true, child:MainCardTransitionContainer(),) : Container(), // the layer with opacity 
              ]),

Try this

Stack(children: [
                currIndex == 1 ? MainCardTransitionContainer() : Container(), // the layer with opacity
                Scaffold(
                  body: SafeArea(
                    child: Container(
                      color: Colors.white,
                      child: ListView...,   // the listView I am trying to scroll
                    ),
                  ),
                ),
              ]),

It's because the top widget of stack is kept at background and last widget is placed in foreground.

In short keep background element at top of stack

Related