should_rebuild 0.0.2 should_rebuild: ^0.0.2 copied to clipboard
A widget can prevent Widget unnecessary rebuild.
ShouldRebuild #
A widget can prevent Widget unnecessary rebuild.
Add dependency #
dependencies:
should_rebuild: 0.0.2
Or
dependencies:
should_rebuild:
git:
url: https://github.com/fluttercandies/should_rebuild
Super simple to use #
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 rebuild if counter changes
ShouldRebuild Widget is a generic StatefulWidget,this generic represents the type of Widget returned by the builder method