CustomThemeData.fromJson constructor

CustomThemeData.fromJson(
  1. String json
)

Implementation

factory CustomThemeData.fromJson(String json) {
  final Map<String, dynamic> data = jsonDecode(json);
  return CustomThemeData(
    primaryColor: Color(
      int.parse(data['primaryColor'].toString().replaceAll('#', '0xFF')),
    ),
    accentColor: Color(
      int.parse(data['accentColor'].toString().replaceAll('#', '0xFF')),
    ),
    backgroundColor: Color(
      int.parse(data['backgroundColor'].toString().replaceAll('#', '0xFF')),
    ),
    textColor: Color(
      int.parse(data['textColor'].toString().replaceAll('#', '0xFF')),
    ),
    brightness:
        data['brightness'] == 'dark' ? Brightness.dark : Brightness.light,
    surfaceColor: data['surfaceColor'] != null
        ? Color(
            int.parse(
              data['surfaceColor'].toString().replaceAll('#', '0xFF'),
            ),
          )
        : Colors.white,
    errorColor: data['errorColor'] != null
        ? Color(
            int.parse(
              data['errorColor'].toString().replaceAll('#', '0xFF'),
            ),
          )
        : Colors.red,
    fontFamily: data['fontFamily'],
  );
}