tryEncode static method

List<int>? tryEncode(
  1. String? value, [
  2. StringEncoding type = StringEncoding.utf8
])

Implementation

static List<int>? tryEncode(String? value,
    [StringEncoding type = StringEncoding.utf8]) {
  if (value == null) return null;
  try {
    return encode(value, type);
  } catch (e) {
    return null;
  }
}