![](/img/trans.png)
[英]How to convert string to list and get the length of the list in Flutter?
[英]How to convert list to string in Flutter?
我有一个清单。 我想将其转换为字符串。 但是,结果与我的预期有点不同。
预期结果:
'["a", "b", "c", "d"]'
实际结果:
[a, b, c, d]
我的代码:
final List list = ["a", "b", "c", "d"];
print(list.toString());
我怎样才能得到我预期的结果? 我将不胜感激任何帮助。 先感谢您!
您可以使用它的jsonEncode
来获得所需的结果:
print(jsonEncode(list));
您可以使用json.encode()
function 简单地执行此操作:
final list = ['a', 'b', 'c', 'd'];
final result = json.encode(list);
您可以尝试jsonEncode
:
final List list = ["a", "b", "c", "d"];
print(jsonEncode(list));
Output:
["a","b","c","d"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.