cssText method

String cssText()

Implementation

String cssText() {
  final function = tileMode == TileMode.clamp ? 'radial-gradient' : 'repeating-radial-gradient';
  var radiusText = radius != 0.5 ? '${radius * 100 * 2}% ' : '';
  if (center is FractionalOffset) {
    final offset = center as FractionalOffset;
    if (offset.dx != 0.5 || offset.dy != 0.5) {
      radiusText += '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($radiusText${colorTexts.join(', ')})';
}