How to use differents ScrollController to NestedScrollView, and two CustomScrollView inside tabls?

Viewed 531

I am using a NestedScrollView widget with TabBar, I have two tabs, and in each tab page view there a CustomScrollView. When I use three different ScrollController to each one, they stop to behave like a traditional sliver, it means when I scroll some CustomScrollView the Sliver Header doesn't hide. How can I control the three ScrollController separately?

2 Answers

Can you show the code? because it's difficult to understand your case. Anyway I show you my code from one of my projects, maybe it helps

Widget build(BuildContext context) {
widget.userBloc = BlocProvider.of<UserBloc>(context);
return Scaffold(
  body: NestedScrollView(
      headerSliverBuilder: (context, innerBoxIsScrolled) =>
      [
        SliverOverlapAbsorber(
          // ignore: deprecated_member_use
          child: SliverSafeArea(
            top: false,
            sliver: SliverAppBar(
              title: Text(
                '',
                style: TextStyle(
                  fontFamily: "Lato",
                  fontSize: 15,
                  //                        fontWeight: FontWeight.bold
                  ),
                ),
              centerTitle: true,
              expandedHeight: 100,
              floating: true,
              flexibleSpace: FlexibleSpaceBar(
                titlePadding: EdgeInsets.only(bottom: 25),
                title: Text(
                  'Hospedajes',
                  style: TextStyle(
                    fontFamily: "Lato",
                    fontSize: 24,
                    fontWeight: FontWeight.bold
                    ),
                  ),
                centerTitle: true,
                background: GradientBack(height: null,),
                ),
              ),

            ),
          handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
          )
      ],

      body: StreamBuilder(
    stream: widget.userBloc.authStatus,
    builder: (BuildContext context, AsyncSnapshot snapshot){
      switch (snapshot.connectionState){
        case ConnectionState.waiting:
          return Center(child: CircularProgressIndicator(),);
        case ConnectionState.none:
          return Center(child: CircularProgressIndicator(),);
        case ConnectionState.active:
          return showUserLodgingsData(snapshot);
        case ConnectionState.done:
          return showUserLodgingsData(snapshot);
        default:
          return showUserLodgingsData(snapshot);
      }
    },
      ),
      ),
  );
 }

you should use tab controller and primary scroll controller to solve such an issue

Related