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 一切正常

相关推荐
我就是妖怪7 小时前
KMP全栈开发:从Android到AI Agent的技术演进与实践
android·人工智能
心平气和量大福大8 小时前
android-实例-蒲公英-更新与安装-5-签名与生成APK
android·java·开发语言
阿pin9 小时前
Android随笔-Serializable与Parcelable
android·serializable·parcelable
天空之城--10 小时前
Android 事件分发机制深度解析——原理、源码与实战综合总结
android
大龄秃头程序员10 小时前
一次 Flutter 动画 Demo 的整理与复盘
flutter
阿pin10 小时前
Android随笔-AIDL
android·开发语言·aidl
2501_9160074711 小时前
Bundle ID 注册与管理 App ID 创建指南 命名规则 权限开关与删除注意事项
android·ios·小程序·https·uni-app·iphone·webview
雨白11 小时前
面向对象六大基本原则实战:从零重构支持引擎切换的网络框架
android·架构
张赐荣12 小时前
Android TalkBack 无障碍优化: 为控件自定义转子导航动作
android·microsoft
AlexMaybeBot13 小时前
躺在沙发上开发 Openclaw 的移动端APP
前端·flutter