setCustomTheme method

  1. @override
Future<void> setCustomTheme(
  1. CustomThemeData theme
)
override

Implementation

@override
Future<void> setCustomTheme(CustomThemeData theme) async {
  final json = {
    'primaryColor':
        '#${theme.primaryColor.toARGB32().toRadixString(16).substring(2)}',
    'accentColor':
        '#${theme.accentColor.toARGB32().toRadixString(16).substring(2)}',
    'backgroundColor':
        '#${theme.backgroundColor.toARGB32().toRadixString(16).substring(2)}',
    'textColor':
        '#${theme.textColor.toARGB32().toRadixString(16).substring(2)}',
    'brightness': theme.brightness == Brightness.dark ? 'dark' : 'light',
    'surfaceColor':
        '#${theme.surfaceColor.toARGB32().toRadixString(16).substring(2)}',
    'errorColor':
        '#${theme.errorColor.toARGB32().toRadixString(16).substring(2)}',
    if (theme.fontFamily != null) 'fontFamily': theme.fontFamily,
  };
  await _prefs.setString(_customThemeKey, jsonEncode(json));
}