List Extension | List Methods | List Properties

List Extension | List Methods | List Properties

List Extension:

Lists in Dart implement the Iterable interface, which provides a set of methods for traversing the elements in the list.

Iterable<E>

List Methods:

  1. add()

  2. addAll()

  3. insert()

  4. remove()

  5. removeAt()

  6. removeLast()

  7. removeRange()

  8. clear()

  9. indexOf()

  10. lastIndexOf()

  11. sort()

  12. forEach()

  13. map()

  14. where()

  15. toList()

  16. getRange()

  17. sublist()

  18. asMap()

List Properties:

  • first: It returns the first element in the List.

  • last: It returns the last element in the List.

  • isEmpty: It returns true if the List is empty and false if the List is not empty.

  • isNotEmpty: It returns true if the List is not empty and false if the List is empty.

  • length: It returns the length of the List.

  • reversed: It returns a List in reverse order.

  • single: It is used to check if the List has only one element and returns it.