transform method

  1. @override
String transform(
  1. Token token
)
override

Implementation

@override
String transform(Token token) {
  final value = token.value;

  if (value is! Map<String, dynamic>) {
    throw Exception('Composition value should be a map');
  }

  final values = value;

  final size = _getSize(values);
  final padding = _getPadding(values);
  final gradient = _getGradient(values);
  final fill = _getFill(values);
  final spacing = _getSpacing(values);
  final borderRadius = _getBorderRadius(values);
  final borders = _getBorders(values, borderRadius != null);
  final shadows = _getShadows(values);
  final textStyle = _getTextStyle(values);
  final opacity = _getOpacity(values);

  final params = [
    size,
    padding,
    gradient ?? fill, // Cannot be applied at the same time
    spacing,
    borderRadius,
    borders,
    shadows,
    textStyle,
    opacity,
  ].where((e) => e != null).join(',\n  ');

  return '''
CompositionToken(
$params,
)''';
}