safeElementAt method
Safely gets an element from the list at the given index
.
Returns null if the index
is out of bounds.
Implementation
T? safeElementAt([int? index]) {
if (index == null) return null;
return (index >= 0 && index < length) ? this[index] : null;
}