operator [] method Null safety

dynamic operator [](
  1. dynamic keyOrIndex
)

Returns an element of data by index or key.

keyOrIndex may be a String or int.

When data is a Map, keyOrIndex must be a String and will return the object for the key in that map.

When data is a List, keyOrIndex must be a int and will return the object at the index in that list.

Implementation

dynamic operator [](dynamic keyOrIndex) {
  return data[keyOrIndex];
}