fromBase64 static method

String? fromBase64(
  1. dynamic s
)

fromBase64() but safe to use on null

Implementation

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