This post demonstrates a few methods to convert String to Byte array in Dart.
import 'dart:convert';
void main() {
final coflutter = 'Coflutter';
print('UTF8 : ${utf8.encode(coflutter)}');
print('Runes : ${coflutter.runes.toList()}');
print('Code units : ${coflutter.codeUnits}');
}
Output
UTF8 : [67, 111, 102, 108, 117, 116, 116, 101, 114]
Runes : [67, 111, 102, 108, 117, 116, 116, 101, 114]
Code units : [67, 111, 102, 108, 117, 116, 116, 101, 114]
Thanks