nyColorStyle<T> function

T nyColorStyle<T>(
  1. BuildContext context, {
  2. String? themeId,
})

Helper to get the color styles Find a color style from the Nylo's appThemes.

Implementation

T nyColorStyle<T>(BuildContext context, {String? themeId}) {
  List<AppTheme> appThemes = Nylo.getAppThemes();

  if (themeId == null) {
    AppTheme themeFound = appThemes.firstWhere((theme) {
      if (context.isDarkMode) {
        return theme.id == getEnv('DARK_THEME_ID');
      }
      return theme.id == ThemeProvider.controllerOf(context).currentThemeId;
    }, orElse: () => appThemes.first);
    return (themeFound.options as NyThemeOptions).colors;
  }

  AppTheme themeFound = appThemes.firstWhere((theme) => theme.id == themeId,
      orElse: () => appThemes.first);
  return (themeFound.options as NyThemeOptions).colors;
}