在flutter 頁面中,如果存在定時器操作或者人為的 頻繁操作setState({});刷新
頁面需要更新的頁面結構可以用 RepaintBoundary組件嵌套,flutter 會將包含的組件獨立出一層"畫布",去繪制。
//頻繁刷新的性能節約嵌套組件 RepaintBoundary return RepaintBoundary( child: Text( "${showTime}", // softWrap: true, // textAlign: TextAlign.left, // overflow: TextOverflow.ellipsis, // maxLines: 3, style: widget.style ?? TextStyleConstant().origin_16, ), );
源代碼的解釋 創建隔離重繪的小部件 所以性能可以省很多