PageView.builder不断重新缓存静态图像

时间:2019-01-19 03:27:40

标签: android image dart flutter flutter-layout

我有一个音乐播放屏幕,在专辑屏幕上滑动即可播放下一首曲目。我正在使用PageView.builder填充曲目列表。

我启用了checkerboardRasterCacheImages标志,并对视频进行了屏幕截图。这是链接:https://streamable.com/1oi6h

问题在于相册图像不断被重新缓存,这会导致丢帧,从而导致60 fps以下的场景。

我尝试用RepaintBoundary小部件包装我的小部件,但它仍重新缓存图像。 还尝试消除背景模糊。

                      AspectRatio(
                        aspectRatio: 1.0 / 1.0,
                        child: Container(
                          width: media.size.width,
                          child: PageView.builder(
                              controller: _pageController,
                              onPageChanged: (int idx) {
                                if (idx < _pageController.page)
                                  prev();
                                else
                                  next();
                              },
                              itemCount: widget.playlist.length(),
                              itemBuilder: (context, index) {
                                return Padding(
                                  padding: media.padding.add(
                                      EdgeInsets.all(40)),
                                  child: DecoratedBox(
                                    decoration: new BoxDecoration(
                                        image: DecorationImage(
                                          image: widget.playlist
                                              .get(index)
                                              .albumArt,
                                          fit: BoxFit.fill,
                                        ),
                                        boxShadow: [
                                          new BoxShadow(
                                              color: Colors.black
                                                  .withOpacity(
                                                  0.5),
                                              offset: new Offset(2.0, 2.0),
                                              blurRadius: 5.0,
                                              spreadRadius: 5.0)
                                        ]
                                    ),
                                  ),
                                );
                              }),
                        ),
                      ),

我期望,因为它是静态图像,所以不应重新缓存每个帧。另外,这是我的第一个应用程序,也是第一次在这里发布,因此如果需要更多信息/代码,请随时询问所需信息。 谢谢。

0 个答案:

没有答案