should_rebuild
위젯은 자식 위젯의 불필요한 재구성 방지할 수 있습니다. 재구성 조건을 사용자 정의할 수 있습니다.
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 ↗