operator [] method

dynamic operator [](
  1. int index
)

Gets the element at the specified index.

Parameters:

  • index: The index of the element.

Returns:

  • The element at the specified index.

Throws:

  • Exception if the index is out of range.

Implementation

operator [](int index) {
  if (rawValue == null) {
    return null;
  }
  if (index < 0 || index >= rawValue!.length) {
    throw Exception("Index $index is out of range");
  }
  return rawValue![index];
}