loadBuiltinThemes static method

Future<void> loadBuiltinThemes()

These are hard coded themes that are loaded before anything so the program wont crash

Implementation

static Future<void> loadBuiltinThemes() async {
  const List<String> builtinThemes = <String>[
    "Default Dark",
    "Default Dark 2",
    "Default Light",
    "Default Light 2"
  ];
  int i = 0;
  for (String r2 in builtinThemes) {
    String r = r2.toLowerCase().replaceAll(" ", "_");
    ThemeData? theme = ThemeDecoder.decodeThemeData(
        jsonDecode(await rootBundle.loadString("assets/$r.json")));
    if (theme != null) {
      ThemeData better = theme.copyWith(
        textTheme: theme.textTheme
            .apply(fontFamily: Shared.FONT_FAMILY_SANS),
        primaryTextTheme: theme.primaryTextTheme
            .apply(fontFamily: Shared.FONT_FAMILY_SANS),
      );
      export.add(_gen(id: r, data: better));
      AvailableTheme.export.add(AvailableTheme(
          r2, r, Icons.palette_rounded, "Builtin", true));
    } else {
      throw "BUG WITH LOADING DEFAULT THEME! 049_$i";
    }
    i++;
    Debug().info("Loaded builtin theme: $r");
  }
}