Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 飞镖/颤振贴图有空奇怪的空键,导致一个值_String_Flutter_Dictionary_Dart_Key - Fatal编程技术网

String 飞镖/颤振贴图有空奇怪的空键,导致一个值

String 飞镖/颤振贴图有空奇怪的空键,导致一个值,string,flutter,dictionary,dart,key,String,Flutter,Dictionary,Dart,Key,这真是不可思议 我有一个非常复杂的类,它应该使用对象而不是疯狂嵌套的数组。无论如何,当要保存所有内容时,我的主要数据结构loanItemDetails会有一个奇怪的附录。我已经把它打印到日志上了 loanItemDetails={:{exists:true},roundCakeTin:{charges:true,rent:5,exists:true}…} 分解如下: keys=(,roundCakeTin values=({exists:true},{charges:true,rent:5,ex

这真是不可思议

我有一个非常复杂的类,它应该使用对象而不是疯狂嵌套的数组。无论如何,当要保存所有内容时,我的主要数据结构loanItemDetails会有一个奇怪的附录。我已经把它打印到日志上了

loanItemDetails={:{exists:true},roundCakeTin:{charges:true,rent:5,exists:true}…}

分解如下:

keys=(,roundCakeTin

values=({exists:true},{charges:true,rent:5,exists:true}

这是不需要的。我如何查找空键?是这样吗?还是一个空字符串用作键?或者。。。?
我已经开始研究我分配给
“存在”的任何地方:true
,但这很痛苦,我希望改进直觉。

如果你想从字典中删除空值,你可以使用以下方法:

void main() {
  final map = {'text': null, 'body': 5, null: 'crap', 'number': 'ten'};

  map.removeWhere((key, value) => key == null || value == null);

  print(map); // {body: 5, number: ten}
}
在你的问题中,我看不到你原来的数据结构。如果你进一步扩展,我可以改进这个答案