getTop<T> method

T getTop<T>()

Implementation

T getTop<T>() {
  dynamic object;
  for (int i = list.length - 1; i >= 0; i--) {
    dynamic e = list[i];
    if (e is T) {
      object = e;
      break;
    }
  }
  if (object == null) {
    throw '"$T" not found. You need to call "push($T())" first or check if exist using contains<$T>() first';
  }
  return object as T;
}