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

相关推荐
灰灰勇闯IT1 小时前
Flutter for OpenHarmony:自定义 Paint 绘图 —— 释放 Canvas 的创造力
flutter
2601_949833391 小时前
flutter_for_openharmony口腔护理app实战+预约管理实现
android·javascript·flutter
牛马1114 小时前
Flutter OverlayEntry
flutter
2603_949462104 小时前
Flutter for OpenHarmony社团管理App实战:预算管理实现
android·javascript·flutter
2601_949975796 小时前
Flutter for OpenHarmony艺考真题题库+帮助中心实现
flutter
王泰虎6 小时前
安卓开发日记,因为JCenter 关闭导致加载不了三方库应该怎么办
android
子春一8 小时前
Flutter for OpenHarmony:构建一个 Flutter 井字棋游戏,深入解析状态驱动逻辑、胜利判定与极简交互设计
flutter·游戏·交互
雨季6669 小时前
Flutter 三端应用实战:OpenHarmony “极简手势轨迹球”——指尖与屏幕的诗意对话
开发语言·javascript·flutter
ujainu9 小时前
Flutter + OpenHarmony 游戏开发进阶:CustomPainter 手绘游戏世界——从球体到轨道
flutter·游戏·信息可视化·openharmony
雨季6669 小时前
Flutter 三端应用实战:OpenHarmony “专注时光盒”——在碎片洪流中守护心流的数字容器
开发语言·前端·安全·flutter·交互