buildValue method

  1. @override
String buildValue(
  1. dynamic value
)
override

Builds the value for the specific type.

Make sure to only override this method with any new DesignTokenParser you create. Please avoid directly calling this method outside DesignTokenParser. Prefer DesignTokenParser.parse.

Implementation

@override
String buildValue(value) {
  if (config != null && config!.fontConfig.isNotEmpty) {
    final mappedFonts = config!.fontConfig;
    if (!mappedFonts.any((element) => element.family == value)) {
      return '\'$value\'';
    }

    final currentFont =
        mappedFonts.firstWhere((element) => element.family == value);

    return '\'${currentFont.flutterName}\'';
  }

  return '\'$value\'';
}