flutter 頁面頻繁刷新節省頁面性能的組件RepaintBoundary


在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,
      ),
  );
源代碼的解釋 創建隔離重繪的小部件 所以性能可以省很多

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM