letAsStringOrNull function

String? letAsStringOrNull(
  1. dynamic input
)

Converts input to String, returning Null on failure.

null in produces null out — never the literal four-character string 'null' that null.toString() would otherwise yield. Leaking that sentinel into a medical record is unacceptable, so the null guard is the safer default.

Supported types:

Implementation

String? letAsStringOrNull(dynamic input) {
  if (input == null) return null;
  try {
    return input.toString();
  } catch (_) {
    return null;
  }
}