What is the difference between functions and classes to create reusable widgets?

Edit: The Flutter team has now taken an official stance on the matter and stated that classes are preferable. See https://www.youtube.com/watch?v=IOyq-eTRhvo TL;DR: Prefer using classes over functions to make reusable widget-tree. EDIT: To make up for some misunderstanding: This is not about functions causing problems, but classes solving some. Flutter wouldn’t have StatelessWidget if a … Read more

How to deal with unwanted widget build?

The build method is designed in such a way that it should be pure/without side effects. This is because many external factors can trigger a new widget build, such as: Route pop/push Screen resize, usually due to keyboard appearance or orientation change The parent widget recreated its child An InheritedWidget the widget depends on (Class.of(context) … Read more