fluttercandies / extended_nested_scroll_view

extended nested scroll view to fix following issues. 1.pinned sliver header issue 2.inner scrollables in tabview sync issue 3.pull to refresh is not work. 4.do without ScrollController in NestedScrollView's body
MIT License
592 stars 119 forks source link

Fixing Vertical viewport was given unbounded height. #48

Closed pishguy closed 2 years ago

pishguy commented 3 years ago

how can i put this library into CustomScrollView? i get this error:

Vertical viewport was given unbounded height.

i used the library sample code and added CustomScrollView to parent of NestedScrollViewRefreshIndicator

return CustomScrollView(
  physics: const ClampingScrollPhysics(),
  slivers: <Widget>[
    SliverPadding(
      padding: const EdgeInsets.all(0),
      sliver: SliverList(
        delegate: SliverChildListDelegate([
          NestedScrollViewRefreshIndicator(
            onRefresh: onRefresh,
            child: NestedScrollView(
                headerSliverBuilder: (BuildContext c, bool f) {
                  return buildSliverHeader();
                },
                //1.[pinned sliver header issue](https://github.com/flutter/flutter/issues/22393)
                pinnedHeaderSliverHeightBuilder: () {
                  return pinnedHeaderHeight;
                },
                //2.[inner scrollables in tabview sync issue](https://github.com/flutter/flutter/issues/21868)
                innerScrollPositionKeyBuilder: () {
                  String index = 'Tab';
                  if (primaryTC.index == 0) {
                    index +=
                        primaryTC.index.toString() + secondaryTC.index.toString();
                  } else {
                    index += primaryTC.index.toString();
                  }
                  return Key(index);
                },
                body: Column(
                  children: <Widget>[
                    TabBar(
                      controller: primaryTC,
                      labelColor: Colors.blue,
                      indicatorColor: Colors.blue,
                      indicatorSize: TabBarIndicatorSize.label,
                      indicatorWeight: 2.0,
                      isScrollable: false,
                      unselectedLabelColor: Colors.grey,
                      tabs: const <Tab>[
                        Tab(text: 'Tabqq0'),
                        Tab(text: 'Tab1'),
                      ],
                    ),
                    Expanded(
                      child: TabBarView(
                        controller: primaryTC,
                        children: <Widget>[
                          SecondaryTabView('Tab0', secondaryTC, true),
                          NestedScrollViewInnerScrollPositionKeyWidget(
                            const Key('Tab1'),
                            GlowNotificationWidget(
                              ListView.builder(
                                //store Page state
                                key: const PageStorageKey<String>('Tab1'),
                                physics: const ClampingScrollPhysics(),
                                itemBuilder: (BuildContext c, int i) {
                                  return Container(
                                    alignment: Alignment.center,
                                    height: 60.0,
                                    child: Text(const Key('Tab1').toString() +
                                        ': ListView$i'),
                                  );
                                },
                                itemCount: 50,
                              ),
                              showGlowLeading: false,
                            ),
                          )
                        ],
                      ),
                    )
                  ],
                )),
          )
        ]),
      ),
    )
  ],
);