serialize method
Implementation
@override
String serialize({String? nameOverride}) {
final resolvedVariableName = nameOverride ?? variableName;
String colorVariables = "";
String mapContent = "";
String primaryValue = "";
for (var value in configs) {
final colorVarName =
'_$resolvedVariableName${value.name.replaceRange(0, 1, value.name[0].toUpperCase())}';
colorVariables += "${value.serialize(nameOverride: colorVarName)}\n";
mapContent += "'${value.name}' : $colorVarName,\n";
if (value.primary == true || primaryValue.isEmpty) {
primaryValue = value.hexString;
}
}
String resultedSerialize = '''
static const Map<String, Color> _${resolvedVariableName}ColorMap = {
$mapContent
};
static const $resolvedVariableName = $shadedClassName($primaryValue, _${resolvedVariableName}ColorMap);
''';
return "$colorVariables$resultedSerialize";
}