dart-lang / collection

The collection package for Dart contains a number of separate libraries with utility functions and classes that makes working with collections easier.

Home Page:https://pub.dev/packages/collection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add List.getOrNull()

windrunner414 opened this issue · comments

add a extension function getOrNull(int index) on List to get element at the specified index safely. If out of bounds, return null.
It can work well with nnbd.

ref: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/get-or-null.html

This should be on Iterable since elementAt is there. Also it might be named elementAtOrNull for consistency.