strToBytes static method
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;
}
}