void main() {
var details = {'LastName':'Martin','FirstName':'Pierre'};
print(details.keys);
}
It will produce the following output : (LastName, FirstName)
But How can I print "LastName" only ?
void main() {
var details = {'LastName':'Martin','FirstName':'Pierre'};
print(details.keys);
}
It will produce the following output : (LastName, FirstName)
But How can I print "LastName" only ?
As defined in dart docs the method Map.keys returns an Iterable object, that is in iteself an iterable (List) like object. You can access the first element of an iterable with the first getter method. And you can use last to access the last element of an Iterable
void main() {
var details = {'LastName':'Martin','FirstName':'Pierre'};
print(details.keys.first); //LastName
print(details.keys.last); //FirstName
}