getFullString method

Future<String?> getFullString(
  1. ThreadInfo thread,
  2. InstanceRef? ref
)

Helper to convert to InstanceRef to a complete untruncated unquoted String, handling vm.InstanceKind.kNull which is the type for the unused fields of a log event.

Implementation

Future<String?> getFullString(ThreadInfo thread, vm.InstanceRef? ref) async {
  if (ref == null || ref.kind == vm.InstanceKind.kNull) {
    return null;
  }
  return _converter
      .convertVmInstanceRefToDisplayString(
    thread,
    ref,
    // Always allow calling toString() here as the user expects the full
    // string they logged regardless of the evaluateToStringInDebugViews
    // setting.
    allowCallingToString: true,
    allowTruncatedValue: false,
    format: VariableFormat.noQuotes(),
  )
      // Fetching strings from the server may throw if they have been
      // collected since (for example if a Hot Restart occurs while
      // we're running this) or if the app is terminating. Log the error and
      // just return null so nothing is shown.
      .then<String?>(
    (s) => s,
    onError: (Object e) {
      logger?.call('$e');
      return null;
    },
  );
}