encode static method
Encodes the given data
bytes to a Base64 string.
noPadding
: If true, removes the '=' padding characters from the output.
Defaults to false (padding included).
urlSafe
: If true, uses URL-safe Base64 encoding by replacing '+' with '-'
and '/' with '_'. Defaults to false (standard Base64).
Returns the Base64-encoded string.
Implementation
static String encode(List<int> data,
{bool noPadding = false, bool urlSafe = false}) {
final encoder = _Base64StreamEncoder();
try {
encoder.add(data.asBytes);
String b64 = encoder.finalize();
if (urlSafe) {
b64 = b64.replaceAll('+', '-').replaceAll('/', '_');
}
if (noPadding) {
b64 = b64.replaceAll('=', '');
}
return b64;
} finally {
encoder.clean();
}
}