Flutter 3.29.3 花屏问题记录

文章目录

Flutter 3.29.3 花屏问题记录

问题记录

flutter版本3.29.3,代码大致为:

复制代码
 ShaderMask(
              shaderCallback: (Rect bounds) {
                return LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [
                    Colors.transparent, // 透明
                    Colors.transparent, // 透明
                    Colors.black, // 渐变到不透明
                    Colors.black,
                    Colors.black,
                  ],
                  stops: [0.0, position, position + 0.03, 0.9, 1.0],
                ).createShader(bounds);
              },
              blendMode: BlendMode.dstIn, // 让渐变应用到内容上,会让内容被透明区域 "擦除",实现顶部消失的效果。
              child: Selector<RoleChatPageViewModel, BotGetData?>(
                selector: (_, vm) => vm.botGetData,
                builder: (_, botInfo, child) {
                  return NotificationListener<ScrollNotification>(
                    onNotification: (notification) {
                      if (notification is UserScrollNotification) {
                        // println('用户拖动方向: ${notification.direction}');
                        if (notification.direction == ScrollDirection.forward) {
                          _handleScrollDirection(isScrollUp: true);
                        } else if (notification.direction ==
                            ScrollDirection.reverse) {
                          _handleScrollDirection(isScrollUp: false);
                        }
                      } else if (notification is ScrollStartNotification) {
                        // println('开始滚动');
                      } else if (notification is ScrollUpdateNotification) {
                        // println('滚动更新');
                      } else if (notification is ScrollEndNotification) {
                        // println('滚动结束');
                      }
                      return false;
                    },
                    child:  /// child;
                },
              ),
            )

用到了ShaderMask 组件,加上这个页面放置在pageView中,可以频繁滑动切换。

在中低端手机上如果滑动快速,非常容易导致花屏。

解决尝试

后续定位可能是ShaderMask 的问题,在安卓机上尤为明显,即便安卓关闭硬件加速也可能导致,去掉该组件则一切正常。

但是设计需要ShaderMask完成功能,后发现flutter不同版本有差异。

解决

切换版本到3.27.3 一切正常

相关推荐
芝麻开门-新起点19 分钟前
Flutter 项目全流程指南:编译、调试与发布
flutter
星释25 分钟前
鸿蒙Flutter三方库适配指南:11.插件发布上线及使用
flutter·华为·harmonyos
jingling5551 小时前
Flutter | 基础环境配置和创建flutter项目
前端·flutter
西西学代码1 小时前
Flutter---DragTarget(颜色拖拽选择器)
前端·javascript·flutter
芝麻开门-新起点2 小时前
Flutter 移动端性能优化指南:内存、电量与 UI 渲染
flutter·ui·性能优化
沐怡旸3 小时前
【底层机制】垃圾回收(GC)底层原理深度解析
android·面试
whatever who cares4 小时前
android/java中gson的用法
android·java·开发语言
用户0273851840264 小时前
【Android】活动的正/异常生命周期和启动模式、标志位详解
android
nono牛5 小时前
MTK平台详解`adb devices`输出的序列号组成
android·linux·adb·智能手机