get method
Returns the element at the specified index.
Parameters
index
: The index of the element to return
Returns
- The element at the specified index
Throws
LangException
if the index is out of bounds
Example
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.get(2); // 3
Implementation
T get([int index = 0]) {
try {
return elementAt(index);
} catch (e) {
throw LangException("Failed to get element at index $index. Found $length items");
}
}