decodeUtf8Text function

String? decodeUtf8Text(
  1. Uint8List bytes
)

Decodes bytes as strict UTF-8 text, or returns null for binary content (omp's decodeUtf8Text: NUL bytes or malformed UTF-8 mark binary).

Implementation

String? decodeUtf8Text(Uint8List bytes) {
  if (bytes.contains(0)) return null;
  try {
    return utf8.decode(bytes);
  } on Object {
    return null;
  }
}