Member-only story
Theme Data Hackery, Your First Step Towards Awesome Brand
You cannot impact your brand until you put brand colors in your app, and you need to extend Theme Data to complete that task. Let me show you why and how to extend theme data.
What Does Theme.of(context) Do
What does the Theme.of(context) do? Knowing this will explain why we need to extend Theme Data in a hackery way. That call is part of every Theme that extends or implements the inherited widget Material Theme. And that infrastructure of the Theme class is:
Notice that it’s creating a new instance of ThemeData. Now, for the Dart internal stuff.
Dart Extension methods need to be referenced at the parent object. Notice that the ThemeData that the of method is Not coupled to a ThemeData extension. Thus, if we extend the parent ThemeData class via Dart extension methods, we will never get access to our fields as they are never coupled to that new ThemeData instance.
And notice that the Cupertino version of ThemeData is not CupertinoThemeData, let me show you how…