toBase64Bytes function
Uint8List
toBase64Bytes(
- List<
int> input, { - Base64Codec? codec,
- bool url = false,
- bool padding = true,
Converts 8-bit integer sequence to Base-64 and returns the ASCII bytes.
This is the same as toBase64 but returns the encoded characters as a Uint8List of ASCII codes, skipping the intermediate String.
Parameters:
inputis a sequence of 8-bit integers- If
urlis true, URL and Filename-safe alphabet is used. - If
paddingis true, the output will have padding characters. codecis the Base64Codec to use. It is derived from the other parameters if not provided.
Implementation
Uint8List toBase64Bytes(
List<int> input, {
Base64Codec? codec,
bool url = false,
bool padding = true,
}) {
codec ??= _codecFromParameters(
url: url,
padding: padding,
);
Uint8List out = codec.encoder.convert(input);
if (!padding && _codecsWithPadding.contains(codec)) {
out = Uint8List.fromList(
out.takeWhile((x) => x != codec!.encoder.padding).toList(),
);
}
return out;
}