addString method
void
addString(
- String key,
- String value,
- JsonShrinkStyle style,
- TextSpan space, [
- InlineSpan urlSpanBuilder(
- String url,
- 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));
}
}