Description
There are over 170 instances of Theme.of(context).colorScheme or Theme.of(context) scattered throughout the UI layer.
Why is this a problem?
Constantly repeating Theme.of(context) leads to visual noise and boilerplate in the build methods, making widget code harder to read.
Proposed Solution
Create a centralized BuildContext extension to streamline this framework boilerplate.
Implementation:
extension BuildContextThemeExt on BuildContext {
ThemeData get theme => Theme.of(this);
ColorScheme get colors => Theme.of(this).colorScheme;
}
This allows reducing Theme.of(context).colorScheme.primary down to a much cleaner context.colors.primary globally.
Description
There are over 170 instances of
Theme.of(context).colorSchemeorTheme.of(context)scattered throughout the UI layer.Why is this a problem?
Constantly repeating
Theme.of(context)leads to visual noise and boilerplate in thebuildmethods, making widget code harder to read.Proposed Solution
Create a centralized
BuildContextextension to streamline this framework boilerplate.Implementation:
This allows reducing
Theme.of(context).colorScheme.primarydown to a much cleanercontext.colors.primaryglobally.