fromBase64 method

String fromBase64()

Decodes the string from Base64.

Returns null if the string is not a valid Base64 string.

Example:

"SGVsbG8=".fromBase64(); // Returns "Hello"
"invalid".fromBase64(); // Returns null

Implementation

String fromBase64() {
  if (isEmpty) return '';
  try {
    return utf8.decode(base64Decode(this));
  } catch (_) {
    return '';
  }
}