Created
January 25, 2023 16:19
-
-
Save jasonmcaffee/2ab40e11b5c26f9db51d3bbe9ee5e13c to your computer and use it in GitHub Desktop.
Revisions
-
jasonmcaffee created this gist
Jan 25, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ import 'dart:collection'; HashMap memoizedTextThemes = HashMap<String, String>(); abstract class PacificDesignSystem { String get colorScheme; String get textTheme { if(memoizedTextThemes[colorScheme] == null){ memoizedTextThemes[colorScheme] = 'textTheme for $colorScheme'; print('added memoized entry for $colorScheme'); } return memoizedTextThemes[colorScheme]; } } class PacificLight extends PacificDesignSystem { @override String get colorScheme => "light"; } class PacificDark extends PacificDesignSystem { @override String get colorScheme => "dark"; } void main() { final pLight1 = PacificLight(); final pLight2 = PacificLight(); final pDark1 = PacificDark(); final pDark2 = PacificDark(); print(pLight1.textTheme); print(pLight1.textTheme); print(pLight2.textTheme); print(pLight2.textTheme); print(pDark1.textTheme); print(pDark1.textTheme); print(pDark2.textTheme); print(pDark2.textTheme); }