*thread #11, name = ‘io.flutter.1.io‘, stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=3072

ios iphone 13 pro carsh 滑动列表,内存溢出,超过imit=3072最大值

*thread #11, name = ‘io.flutter.1.io‘, stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=3072_第1张图片

代码如下:

List<Widget> childs = <Widget>[
  BannerWidget(),
  HomeChainsWidget(),
  HomeRecommendedWidget(),
  RecentlyListedWidget(),
  HomeRecentRocketsWidget(),
  HotCollectionsWidget(),
  // HomeRankingsWidget(),
  HotItemsWidget(),
];

 return SmartRefresher(
           enablePullDown: true,
                enablePullUp: true,
                controller: logic.refreshController,
                onRefresh: logic.refresh,
                onLoading: logic.loadMore,
                child: ListView.builder(
                    itemCount: childs?.length,
                    controller: scrollController,
                    addRepaintBoundaries: false,
                    addAutomaticKeepAlives: false,
                    itemBuilder: (_, int index) => childs[index]));

HotItemsWidget(),底部无限滑动列表如下

        GridView.builder(
                  shrinkWrap: true,
                  addAutomaticKeepAlives: false,
                  padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
                  itemCount: logic.hotItemsList?.length ?? 0,
                  physics: NeverScrollableScrollPhysics(),
                  gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
                      maxCrossAxisExtent: gridWidth,
                      crossAxisSpacing: 10.0,
                      mainAxisSpacing: 10.0,
                      childAspectRatio: gridWidth / (gridWidth + 74)),
                  itemBuilder: (BuildContext context, int index) {
                    return _buildHotItems(context, index, gridWidth);
                  }),

查阅资料https://github.com/peng8350/flutter_pulltorefresh/issues/229
*thread #11, name = ‘io.flutter.1.io‘, stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=3072_第2张图片
*thread #11, name = ‘io.flutter.1.io‘, stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=3072_第3张图片
看来问题出在 shrinkWrap: true, 这句话上面,ListView有时候还会重绘image,造成列表图片闪动,滑动还有些卡顿

修改方法 CustomScrollView 代替 listview,并且去除 shrinkWrap: true,
GridView 用SliverGrid代替 这样去除 shrinkWrap: true,了

  return SmartRefresher(
                enablePullDown: true,
                enablePullUp: true,
                controller: logic.refreshController,
                onRefresh: logic.refresh,
                onLoading: logic.loadMore,
                child: CustomScrollView(controller: scrollController, slivers: [
                  BannerWidget(),
                  HomeChainsWidget(),
                  HomeRecommendedWidget(),
                  RecentlyListedWidget(),
                  HomeRecentRocketsWidget(),
                  HotCollectionsWidget(),
                  HotItemsTitleWidget(),
                  HotItemsWidget(),
                ]));
SliverPadding(
              padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
              sliver: SliverGrid(
                delegate: SliverChildBuilderDelegate(
                        (_, index) => _buildHotItems(
                        context, index, GameFiController.to.gridWidth),
                    childCount: logic.hotItemsList?.length ?? 0),
                gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
                    maxCrossAxisExtent: 260,
                    crossAxisSpacing: 10.0,
                    mainAxisSpacing: 10.0,
                    childAspectRatio: logic.gridRatio),
              ));

目前还有个问题是EXC_BAD_ACCESS (code=257)问题 这个问题 怀疑是图片过大,目前还在解决中

thread OS Error: Operation not permitted #8, name = 'io.flutter.1.ui', stop reason = EXC_BAD_ACCESS (code=257, address=0x106b08041)
frame #0: 0x0000000106b08041
-> 0x106b08041: udf #0x9601
0x106b08045: .long 0x41000000 ; unknown opcode
0x106b08049: .long 0x0106b080 ; unknown opcode
0x106b0804d: ldr w0, 0x106b0804d
Target 0: (Runner) stopped.

你可能感兴趣的:(flutter)