index property
int?
index
The index of the object when it is an element in a List
Usage:
pick(["John", "Paul", "George", "Ringo"]).asListOrThrow((pick) {
final index = pick.index!;
return Artist(id: index, name: pick.asStringOrThrow());
);
Implementation
int? get index {
final lastPathSegment = path.isNotEmpty ? path.last : null;
if (lastPathSegment == null) {
return null;
}
if (lastPathSegment is int) {
// within a List
return lastPathSegment;
}
return null;
}