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

相关推荐
咋吃都不胖lyh3 小时前
SQL-多对多关系
android·mysql·数据分析
cyy2983 小时前
android 屏幕适配
android
Digitally5 小时前
如何通过 5 种有效方法同步 Android 和 Mac
android·macos
路很长OoO6 小时前
Flutter 插件开发实战:桥接原生 SDK
前端·flutter·harmonyos
行墨7 小时前
Jetpack Compose 深入浅出(二)——基础组件Text
android
雨白8 小时前
深入理解协程的运作机制 —— 调度、挂起与性能
android·kotlin
沐怡旸8 小时前
【Android】Android系统体系结构
android
namehu9 小时前
React Native 应用性能分析与优化不完全指南
android·react native·ios
xqlily9 小时前
Kotlin:现代编程语言的革新者
android·开发语言·kotlin
HelloBan9 小时前
如何正确去掉SeekBar的Thumb和按压效果
android