【问题标题】:Flutter data["dataKey"] How can I return one specific argument?Flutter data["dataKey"] 如何返回一个特定的参数?
【发布时间】:2021-06-14 20:39:58
【问题描述】:

A value of type 'Object?' can't be assigned to a variable of type 'Map<dynamic, dynamic>'. Its a Routing error

我指的是这个问题。我怎样才能返回一个特定的参数? data["dataKey"] 只是给了我所有的论点。

【问题讨论】:

  • 为什么要将它们分配给地图?
  • 使用一个充满命名参数的类,现在需要返回它们。

标签: flutter dart return arguments datakey


【解决方案1】:

你可以这样做-

MapEntry _entry = data.entries.singleWhere((element)=><Expression>);
print(_entry.value);

例子

Map<String, int> data = {'one': 1, 'two': 2};
MapEntry _entry = data.entries.singleWhere((element) => element.key == 
'one');
print(_entry.key);// it will print "one"
print(_entry.value); //it will print 1

【讨论】:

  • 感谢您的快速回答。但是仅通过对print(data["dataKey"] 进行一些修改,我就无法返回一个特定的参数吗?
猜你喜欢
  • 1970-01-01
  • 2020-07-07
  • 1970-01-01
  • 1970-01-01
  • 2017-03-16
  • 2011-07-30
  • 1970-01-01
  • 2022-11-23
  • 1970-01-01
相关资源
最近更新 更多