之前有个项目中需要数字转字符,话不多说,直接上代码:
// int 转 ascii 字符,flutter中没有char类型,可以通过Uint8List来转换 int figure = (Random().nextInt(26)) + 97; print('数字' + figure.toString()); var listInt = [figure]; print('listInt = ' + listInt.toString()); var int2utf8 = Uint8List.fromList(listInt); print('Uint8List = ' + int2utf8.toString()); var character = Utf8Codec().decode(int2utf8); print('character = ' + character); print('数字' + figure.toString() + '=' + character);