将字符串转换为“ uint8list”;到Unit8List [英] convert a String of "uint8list" to a Unit8List

查看:1037
本文介绍了将字符串转换为“ uint8list”;到Unit8List的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储在Sqllite中的内存映像,该内存映像已通过toString()方法转换为String,我想将其转换为Unit8List以便在MemoryImage小部件中显示它

I have a memory image stored in Sqllite converted to String with the toString() method, I want to convert it to Unit8List to display it inside a MemoryImage widget

推荐答案

codeUnits 为您提供 List< int>

Uint8List.fromList(...) List< int> 转换为 Uint8List

String.fromCharCodes(...)转换 List< int> Uint8List String

codeUnits gets you a List<int>
Uint8List.fromList(...) converts List<int> to Uint8List
String.fromCharCodes(...) converts List<int> or Uint8List to String

List<int> list = 'xxx'.codeUnits;
Uint8List bytes = Uint8List.fromList(list);
String string = String.fromCharCodes(bytes);

这篇关于将字符串转换为“ uint8list”;到Unit8List的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆