toString method Null safety

  1. @override
String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string represetion.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

Implementation

@override
String toString() {
  final headers = this.headers?.let(_redactHeaders);

  return [
    'ReplicatorConfiguration(',
    [
      'database: $database',
      'target: $target',
      'replicatorType: ${describeEnum(replicatorType)}',
      if (continuous) 'CONTINUOUS',
      if (authenticator != null) 'authenticator: $authenticator',
      if (pinnedServerCertificate != null) 'PINNED-SERVER-CERTIFICATE',
      if (headers != null) 'headers: $headers',
      if (channels != null) 'channels: $channels',
      if (documentIds != null) 'documentIds: $documentIds',
      if (pushFilter != null) 'PUSH-FILTER',
      if (pushFilter != null) 'PULL-FILTER',
      if (conflictResolver != null) 'CUSTOM-CONFLICT-RESOLVER',
      if (!enableAutoPurge) 'DISABLE-AUTO-PURGE',
      if (heartbeat != null) 'heartbeat: ${_heartbeat!.inSeconds}s',
      if (maxAttempts != null) 'maxAttempts: $maxAttempts',
      if (maxAttemptWaitTime != null)
        'maxAttemptWaitTime: ${_maxAttemptWaitTime!.inSeconds}s',
    ].join(', '),
    ')'
  ].join();
}