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

置顶时候内存激增 #46

Closed Bedroome closed 2 years ago

Bedroome commented 3 years ago
class A extends StatelessWidget {
  final GlobalKey<extended.NestedScrollViewState> globalKey =
      GlobalKey<extended.NestedScrollViewState>();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          globalKey.currentState.currentInnerPosition.jumpTo(0.0);
        },
      ),
      body: extended.NestedScrollView(
        key: globalKey,
        innerScrollPositionKeyBuilder: () {
          return Key('Nest-1-0');
        },
        headerSliverBuilder: (
          BuildContext context,
          bool innerBoxIsScrolled,
        ) {
          final List<Widget> widgets = <Widget>[];
          return widgets;
        },
        body: extended.NestedScrollViewInnerScrollPositionKeyWidget(
          Key('Nest-1-0'),
          CustomScrollView(
            slivers: [
              SliverList(
                delegate: SliverChildBuilderDelegate(
                  (context, index) {
                    print(index);
                    return Image.network(
                      'https://picsum.photos/seed/${Random().nextInt(99999)}/500/500',
                      height: 500,
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

上述代码, 在滑动到比较底部的时候,点击置顶, 会出现内存激增的状况, 如果列表很长, 就会崩溃, 有没有什么别的办法,能解决这个问题吗, 如果不用动画, 我用动画如果时间设置较长才会没有这个问题.

截屏2020-08-18 下午8 24 27

这是ios的监控图 后面那段比较高的就是我点击了置顶

1xiaocainiao commented 3 years ago

我也遇到了,怎么解决啊

zmtzawqlp commented 3 years ago

如何管理图片内存,请参考 https://github.com/fluttercandies/extended_image#memoryusage