addString method

void addString(
  1. String key,
  2. String value,
  3. JsonShrinkStyle style,
  4. TextSpan space, [
  5. InlineSpan urlSpanBuilder(
    1. String url,
    2. JsonShrinkStyle style
    )?,
])

Implementation

void addString(
  String key,
  String value,
  JsonShrinkStyle style,
  TextSpan space, [
  InlineSpan Function(String url, JsonShrinkStyle style)? urlSpanBuilder,
]) {
  add(space);
  add(TextSpan(text: '"$key"', style: style.keyStyle));
  add(TextSpan(text: ':', style: style.symbolStyle));
  if (isUrl(value)) {
    if (urlSpanBuilder != null) {
      add(urlSpanBuilder.call(value, style));
    } else {
      add(
        TextSpan(
          text: '"$value"',
          style: style.urlStyle,
          recognizer: LongPressGestureRecognizer()
            ..onLongPress =
                () => Clipboard.setData(ClipboardData(text: value)),
        ),
      );
    }
    /*if (isImageUrl(value)) {
      String imageUrl = value.replaceAll('\\/', '/');
      add(
        WidgetSpan(
          child: GestureDetector(
            child: CachedNetworkImage(imageUrl: imageUrl, width: 30, height: 30, fit: BoxFit.cover),
            onLongPress: () => Clipboard.setData(ClipboardData(text: imageUrl)),
          ),
        ),
      );
    } else {
      add(
        TextSpan(
          text: '"$value"',
          style: style?.urlStyle,
          recognizer: LongPressGestureRecognizer()..onLongPress = () => Clipboard.setData(ClipboardData(text: value)),
        ),
      );
    }*/
  } else {
    add(TextSpan(text: '"$value"', style: style.textStyle));
  }
}