有没有办法在Flutter中将String转换为Map <dynamic,dynamic>

时间:2020-09-26 16:41:35

标签: json string flutter dynamic

是否可以在Flutter中将String转换为Map

String myString = "mytexthere";

Map<dynamic, dynamic> fieldData = jsonDecode(myString);
Map<dynamic, dynamic> fieldData = new Map<dynamic, dynamic>.from(myString);
Map<dynamic, dynamic> fieldData = myString.cast<dynamic, dynamic>();
Map<dynamic, dynamic> fieldData = Map<dynamic, dynamic>.from(myString);

似乎以上都不起作用?有正确的方法吗?

编辑3: 这是有效的方法:

Map<dynamic, dynamic> fieldData = {"body": myString};

0 个答案:

没有答案