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;
}
}

网友评论