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]
Creator of Coflutter.
Founder & CTO at Bumbii Technology
Founder at Bumbii K12
Follow him on Twitter, Github, StackOverflow, LinkedIn, Upwork.
Thanks