decode static method

String decode(
  1. List<int> value, [
  2. StringEncoding type = StringEncoding.utf8,
  3. bool allowInvalidOrMalformed = false
])

Decodes a list of bytes value into a string using the specified type.

The type parameter determines the decoding type to use, with UTF-8 being the default. Returns the decoded string.

Example:

String decodedString = StringUtils.decode([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]);

Implementation

static String decode(
  List<int> value, [
  StringEncoding type = StringEncoding.utf8,
  bool allowInvalidOrMalformed = false,
]) {
  switch (type) {
    case StringEncoding.utf8:
      return utf8.decode(value, allowMalformed: allowInvalidOrMalformed);
    case StringEncoding.base64:
      return base64Encode(value);
    default:
      return ascii.decode(value, allowInvalid: allowInvalidOrMalformed);
  }
}