customTheme method

void customTheme({
  1. required String name,
  2. required NeomageColorScheme colors,
  3. NeomageTextTheme? text,
  4. NeomageComponentTheme? components,
  5. SyntaxTheme? syntax,
})

Register and activate a user-defined theme.

Implementation

void customTheme({
  required String name,
  required NeomageColorScheme colors,
  NeomageTextTheme? text,
  NeomageComponentTheme? components,
  SyntaxTheme? syntax,
}) {
  final theme = NeomageTheme(
    info: ThemeInfo(
      name: name,
      displayName: name,
      isDark: _looksLikeDark(colors),
    ),
    colors: colors,
    textTheme: text ?? NeomageTextTheme.defaults(color: colors.onBackground),
    componentTheme: components ?? const NeomageComponentTheme(),
    syntaxTheme: syntax ?? NeomageThemes.darkDefault.syntaxTheme,
  );
  _customThemes[name] = theme;
  _currentTheme = theme;
  _controller.add(_currentTheme);
}