title: Decode audio buffer in dart
body: <p>I am using an express server to convert text to speech using aws polly. I can send back the response data as an array of ints and get it to play with the flutter audioplayers package by converting it to Uint8List like the following.</p>
  <pre><code>final res = await post('url',
    headers: {HttpHeaders.contentTypeHeader: 'application/json'},
    body: body,
  );
  final decoded = json.decode(res.body);
  return Uint8List.fromList(decoded['AudioStream']['data'].cast&lt;int&gt;());
  </code></pre>
  <p>My problem is I want to send the audio stream buffer instead of the array of integers but I am struggling to decode it in dart. This is how I am sending the audio from the server I'm just unsure how I can convert it to Uint8List in the flutter app.</p>
  <pre><code>const data =  await Polly.synthesizeSpeech(input).promise()
  res.set('Content-Type', 'audio/mpeg')
  res.send(data.AudioStream)
  </code></pre>
  <p>Edit: When testing in postman I can play the audio from the response. I updated the way I am sending the data from express to the following</p>
  <pre><code>res.send(Buffer.from(data.AudioStream, 'base64'))
  </code></pre>
  <p>but decoding the response in dart like this throws a FormatException, maybe I am doing this part wrong</p>
  <pre><code>Uint8List decoded = Base64Codec().decode(res.body);
  </code></pre>
  <p>exception</p>
  <pre><code>FormatException: Invalid character (at character 4)
  </code></pre>