argsKey function

String argsKey(
  1. Object? args, {
  2. int limit = 200,
})

A truncated argument key, so one enormous body cannot fill the ring.

Implementation

String argsKey(Object? args, {int limit = 200}) {
  final value = args is TagContext ? tagContextJson(args) : args;
  String text;

  try {
    text = value == null
        ? ''
        : jsonEncode(value, toEncodable: (Object? other) => other.toString());
  } on Object {
    // A cyclic or unserialisable argument. Not worth throwing over.
    text = '[unserialisable]';
  }

  return text.length > limit ? '${text.substring(0, limit)}...' : text;
}