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 (value is String) {
    final abs = double.parse(value).toInt();

    if (_allowedWeights.contains(abs)) {
      return 'FontWeight.w$abs';
    } else {
      throw Exception(
        'Unsupported font weight: $value. Please use one of these weights: 100, 200, 300, 400, 500, 600, 700, 800, 900.',
      );
    }
  }

  throw Exception('Unable to parse font weight with data: $value');
}