Are .of(context) calls that expensive?

The golden rule in ANY language is:

  1. It is a property? You can use it wherever you want *
  2. It is a function? Cache it (i.e.: final theme = Theme.of(context) in the beginning of build method)

*: There are some cases where there are violations about this rule, and even Google break it (example: Beware of Color.value's performance)

2 Likes