obscured property

String get obscured

Returns this value as an obscured string.

Intended to be used to obscure sensitive information in Logs:

// - prints `[Type] signIn(password: ***)`, when non-`null`;
// - prints `[Type] signIn(password: null)`, when `null`;
Log.debug('signIn(password: ${password?.obscured})', '$runtimeType');

Implementation

String get obscured {
  if (Config.logObfuscated) {
    return '***';
  }

  return toString();
}