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

相关推荐
YF021119 分钟前
深入剖析 Kotlin 的高效之道与核心实战
android·kotlin·app
BG34 分钟前
Flutter PSD 解析实践:利用ag-psd 解析 + 分块图片编码,同时解决移动端OOM
flutter
程序员码歌1 小时前
别再让 AI 自由发挥了:OpenSpec 才是团队协作不跑偏的关键
android·前端·人工智能
敲代码的鱼1 小时前
NFC读卡能力 支持安卓/iOS/鸿蒙 UTS插件
android·ios·uni-app
刮风那天2 小时前
Android 常驻进程如何被查杀?
android
刮风那天3 小时前
Android 如何降低进程优先级可以被查杀?
android
资源分享助手4 小时前
超级改图P图改字无限制版教程(安卓)AI改图软件、图片改字软件、安卓修图APP、智能消除工具、图片拼接APP、超级改图下载
android·人工智能
Lehjy5 小时前
【Linux】文件系统磁盘存储结构
android·linux·运维
BU摆烂会噶5 小时前
【LangGraph】节点内调用与状态隔离
android·人工智能·python·ui·langchain·人机交互
BU摆烂会噶6 小时前
【LangGraph】作为节点添加与状态共享
android·人工智能·python·ui·langchain·人机交互