v1.0.1
should_rebuild
一個 widget 可以防止子 widget 的不必要的重建。您可以自定重建條件。
29喜歡 899近 30 天下載140Pub 分數
AndroidiOSWebmacOSWindowsLinux
fantasy525/should_rebuild open-source repository details.
以下為英文專案原文快照,最新內容請造訪 GitHub。
A widget can prevent Child Widget unnecessary rebuilds.You can filter whether you need rebuild based on whether the property values received by the old Child Widget and the new Child Widget are equal.
(这个widget可以防止它的child发生不必要的rebuilds,你可以判断新的Child Widget和旧的Child Widget接收的属性值是否相等来过滤是否需要rebuild)
dependencies:
should_rebuild: 1.0.1
Or
dependencies:
should_rebuild:
git:
url: https://github.com/fluttercandies/should_rebuild
ShouldRebuild<Todo>(
shouldRebuild: (oldWidget, newWidget) => oldWidget.counter != newWidget.counter,
child: Todo(counter: counter,)
),
Todo Widget
class Todo extends StatelessWidget {
final int counter;
Todo({this.counter});
@override
Widget build(BuildContext context) {
return Container(
child: Text(counter.toString()),
);
}
}
The Todo widget only rebuilds if counter changes
ShouldRebuild Widget is a generic StatefulWidget,this generic represents the type of Widget returned by the builder method
依賴清單 2 項
{"sdk":"flutter"}{"sdk":"flutter"}先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗