Flutter data["dataKey"] How can I return one specific argument?

95 Views Asked by At

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

Im referring to this question. How can I return one specific argument? data["dataKey"] just gives me all arguments.

1

There are 1 best solutions below

1
On

You can do it like-

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

Example

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