Want to Prevent rerender of a widget based on custom logic in flutter? Usually when you have performance issues because you are rendering too many widgets, you are using ListView or GridView. You can prevent this performance issue by using ListView.builder() or GridView.builder() methods. ListView.builder and GridView.builder will only render the widgets that are on screen, thus preventing performance issues.
Here are some examples:
itemBuilder: (BuildContext context, int index) => _grid(data[index]),
itemBuilder: (BuildContext context, int index) => _listItem(data[index]),
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.