strToBytes static method

Uint8List strToBytes(
  1. String str
)

Implementation

static Uint8List strToBytes(String str) {
  try {
    // First convert string to UTF-8 bytes
    List<int> utf8Bytes = utf8.encode(str);
    return Uint8List.fromList(utf8Bytes);
  } catch (e) {
    print('Encoding error: $e');
    rethrow;
  }
}