Skip to content

Instantly share code, notes, and snippets.

@jasonmcaffee
Created January 25, 2023 16:19
Show Gist options
  • Select an option

  • Save jasonmcaffee/2ab40e11b5c26f9db51d3bbe9ee5e13c to your computer and use it in GitHub Desktop.

Select an option

Save jasonmcaffee/2ab40e11b5c26f9db51d3bbe9ee5e13c to your computer and use it in GitHub Desktop.

Revisions

  1. jasonmcaffee created this gist Jan 25, 2023.
    43 changes: 43 additions & 0 deletions main.dart
    Original 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);
    }