美文网首页
flutter 性能分析

flutter 性能分析

作者: liboxiang | 来源:发表于2019-08-09 17:36 被阅读0次

https://flutter.dev/docs/testing/ui-performance

MaterialApp(
    showPerformanceOverlay: true,
    checkerboardOffscreenLayers: true, //使用了saveLayer的图像会显示为棋盘格式并随着页面刷新而闪烁
    checkerboardRasterCacheImages: true, // 做了缓存的静态图像图片在刷新页面使不会改变棋盘格的颜色;如果棋盘格颜色变了,说明被重新缓存,这是我们要避免的
    ...
);

checkerboardOffscreenLayers Demo和效果

class TestPaint extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    canvas.drawPaint(new Paint()..color = Colors.transparent);
    canvas.drawRect(new Rect.fromLTWH(50.0, 100.0, 200.0, 200.0),
        new Paint()..color = Colors.red);
    canvas.drawRect(
        new Rect.fromLTWH(150.0, 200.0, 200.0, 200.0),
        new Paint()
          ..color = Colors.white
          ..blendMode = BlendMode.dstOut);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) {
    // TODO: implement shouldRepaint
    return true;
  }
}
WeChat21272c3cc78df6411aed484f0da0dbf4.png

相关文章

网友评论

      本文标题:flutter 性能分析

      本文链接:https://www.haomeiwen.com/subject/skhedctx.html