fromBase64 function

Uint8List fromBase64(
  1. String input, {
  2. Base64Codec? codec,
  3. bool padding = true,
})

Converts 6-bit Base-64 character sequence to 8-bit integer sequence.

Parameters:

  • input should be a valid base-64 encoded string.
  • If padding is true, the output will have padding characters.
  • codec is the Base64Codec to use. It is derived from the other parameters if not provided.

Throws:

  • FormatException if the input contains invalid characters, and the length is not valid for a base-64 encoded string.

This implementation can handle both the original and URL/filename-safe alphabets. Any letters appearing after the first padding character is observed are ignored. If a partial string is detected, the following bits are assumed to be zeros.

Implementation

Uint8List fromBase64(
  String input, {
  Base64Codec? codec,
  bool padding = true,
}) {
  codec ??= _codecFromParameters(padding: padding);
  var out = codec.decoder.convert(input.codeUnits);
  return Uint8List.fromList(out);
}