toBase64 static method
toBase64() but safe to use on null
Implementation
static String? toBase64(dynamic s)
{
try
{
if (s is String)
{
var bytes = utf8.encode(s);
return Base64Codec().encode(bytes);
}
if (s is List<int>)
{
return Base64Codec().encode(s);
}
return null;
}
catch(e)
{
return null;
}
}