fromBase64 function
fromBase64() but safe to use on null
Implementation
String? fromBase64(dynamic s) {
try {
if (s is String) {
// length must be divible by 4
while (s.length % 4 != 0) {
s = s + "=";
}
var bytes = const Base64Codec().decode(s);
return utf8.decode(bytes);
}
if (s is List<int>) {
return utf8.decode(s);
}
return null;
} catch (e) {
return null;
}
}