I have realized that it is possible to create widgets using plain functions instead of subclassing StatelessWidget. An example would be this:
Widget functio
Widgets returned by functions are rebuilt every time the widget tree is rebuilt, whether they contain a state or not.
However, stateless or stateful widgets will only be rebuilt (just them) in that widget tree if the state they contain changes.
It is advised to extract the widgets to their separate classes to improve the performance of your app. Minimize how many widgets are rebuilt...