'Flutter NestedScollView body height

I used NestedScrollView to put Tabbar in Scrollview. Everything works fine except the empty space of the bottom screen. I cannot give the height because it should be dynamic. How can I remove the bottom space?

This is the attachment of the problem

This is my code

DefaultTabController(
        length: 2,
        child: Scaffold(
          body: RefreshIndicator(
            key: refreshKey,
            onRefresh: refreshList,
            child: NestedScrollView(
              physics: BouncingScrollPhysics(),
              controller: _scrollController,
              headerSliverBuilder: (context, innerBoxIsScrolled) {
                return [
                  SliverToBoxAdapter(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          height: MediaQuery.of(context).size.width * 0.625,
                          width: MediaQuery.of(context).size.width,
                          color: Colors.white,
                          child: Stack(
                            children: [
                              AspectRatio(
                                aspectRatio: 2 / 1,
                                child: Image.network(
                                    snapshot.data.data()['backgroundImage'],
                                    fit: BoxFit.fitWidth),
                              ),
                              Positioned(
                                bottom: 0,
                                left: MediaQuery.of(context).size.width *
                                    0.08,
                                child: Container(
                                  padding: EdgeInsets.all(5),
                                  height:
                                      MediaQuery.of(context).size.width *
                                          0.25,
                                  width: MediaQuery.of(context).size.width *
                                      0.25,
                                  decoration: BoxDecoration(
                                    shape: BoxShape.circle,
                                    color: Colors.white,
                                  ),
                                  child: ClipOval(
                                    child: snapshot.data
                                                .data()['profile'] !=
                                            ""
                                        ? Image.network(
                                            snapshot.data.data()['profile'],
                                            fit: BoxFit.cover)
                                        : Image.asset(
                                            'assets/emptyprofile.png',
                                            fit: BoxFit.cover),
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                        SizedBox(height: 10),
                        Padding(
                          padding: EdgeInsets.only(left: 20),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(snapshot.data.data()['name'],
                                  style: const TextStyle(
                                      color: const Color(0xff000000),
                                      fontWeight: FontWeight.w700,
                                      fontFamily: "Montserrat",
                                      fontStyle: FontStyle.normal,
                                      fontSize: 24.0),
                                  textAlign: TextAlign.left),
                              SizedBox(height: 5),
                              Text("One line about you",
                                  style: const TextStyle(
                                      color: const Color(0xff000000),
                                      fontWeight: FontWeight.w500,
                                      fontFamily: "Montserrat",
                                      fontStyle: FontStyle.normal,
                                      fontSize: 12.0),
                                  textAlign: TextAlign.left),
                              SizedBox(height: 30),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                  SliverPersistentHeader(
                    floating: true,
                    pinned: true,
                    delegate: _SliverAppBarDelegate(
                      child: PreferredSize(
                        child: Container(
                          decoration: BoxDecoration(
                            color: Colors.white,
                            boxShadow: [
                              BoxShadow(
                                  color: Colors.grey[200],
                                  offset: Offset(0, 3),
                                  blurRadius: 2,
                                  spreadRadius: 0)
                            ],
                          ),
                          padding: EdgeInsets.only(left: 10),
                          child: TabBar(
                            controller: _tabController,
                            isScrollable: true,
                            labelStyle: TextStyle(
                                color: Colors.black,
                                fontWeight: FontWeight.w700,
                                fontFamily: "Montserrat",
                                fontStyle: FontStyle.normal,
                                fontSize: 14.0),
                            indicatorSize: TabBarIndicatorSize.tab,
                            indicatorColor: Colors.black,
                            indicatorWeight: 5,
                            indicatorPadding: EdgeInsets.only(bottom: 0),
                            labelPadding:
                                EdgeInsets.only(left: 20, right: 20),
                            unselectedLabelStyle: TextStyle(
                                color: Colors.black,
                                fontWeight: FontWeight.w500,
                                fontFamily: "Montserrat",
                                fontStyle: FontStyle.normal,
                                fontSize: 14.0),
                            tabs: [
                              Tab(text: 'Portfolio'),
                              Tab(text: "About"),
                            ],
                          ),
                        ),
                        preferredSize: Size.fromHeight(50),
                      ),
                    ),
                  ),
                ];
              },
              body: Container(
                color: Colors.white,
                child: TabBarView(
                  controller: _tabController,
                  children: [
                    _buildBody(context),
                    SizedBox(),
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  },
);}

_buildBody part

Widget _buildBody(BuildContext context) {
List<Gallery> gallerytotalList = Provider.of<List<Gallery>>(context);
List<Gallery> galleryList = [];
for (Gallery gallery in gallerytotalList) {
  if (gallery.author == userID && gallery.hide == false) {
    galleryList.add(gallery);
  }
}

return GridView.count(
  mainAxisSpacing: 7,
  crossAxisSpacing: 7,
  shrinkWrap: true,
  physics: NeverScrollableScrollPhysics(),
  childAspectRatio: 1 / 1,
  padding: EdgeInsets.all(7),
  crossAxisCount: 3,
  children: galleryList.map((e) => _buildItem(context, e)).toList(),
);

}



Solution 1:[1]

Do you want it to be at the bottom? for it to cover that whitespace You can include Spacer() widget the _bodyWidget

body: Container(
                color: Colors.white,
                child: TabBarView(
                  controller: _tabController,
                  children: [
                    Spacer(),
                    _buildBody(context),
                    
                    SizedBox(),
                  ],
                ),
              ),

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DonnC