What is the complexity of Theme.of()
, and since Provider.of()
‘s complexity is O(1) (if I’m correct), would it be better to use Theme.of() or Provider.of() to get the Theme from the context?
So it it better to use
final ThemeData theme = Theme.of(context);
or
final ThemeData theme = Provider.of<ThemeData>(context, listen: false);
And can Theme.of()
cause unwanted rebuilds, and how about Provider.of(context, listen: false)
?
I’m trying to make my app’s rebuilds more predictable without breaking on Flutter updates. And also trying to make sure getting the theme is as fast as possible as it’s done in almost every build method in my app.