cssText method

String cssText()

Implementation

String cssText() {
  final function = 'conic-gradient';
  var from = '';
  if (transform is GradientRotation) {
    final deg = (((transform as GradientRotation).radians + math.pi / 2) * 360 / 2 / math.pi);
    if (deg != 0) {
       from = 'from ${deg.cssText()}deg, ';
    }
  }
  var at = '';
  if (center is FractionalOffset) {
    final offset = center as FractionalOffset;
    if (offset.dx != 0.5 || offset.dy != 0.5) {
      at += 'at ${offset.dx * 100}% ${offset.dy * 100}%, ';
    }
  }

  final colorTexts = [];
  final includeStop = !(stops?.length == 2 && stops?[0] == 0 && stops?[1] == 1);
  for (int i = 0; i < colors.length; i++) {
    var text = CSSColor(colors[i]).cssText();
    if (stops != null && stops![i] >= 0 && includeStop) {
      text += ' ${stops![i] * 100}%';
    }
    colorTexts.add(text);
  }
  return '$function($from$at${colorTexts.join(', ')})';
}