last function
dynamic
last(
- dynamic value
Returns the last element of value.
- Supports
List,Map, andSet. - For maps, returns the last entry.
- Throws Exception if
valueis not a supported type.
Implementation
dynamic last(dynamic value) {
if (value is List) return value.last;
if (value is Map) return value.last();
if (value is Set) return value.last;
throw Exception("Function 'last' is invalid for type "
"'${value.runtimeType}'. Valid types are List, Map, and Set.");
}