binarySearch method

int binarySearch(
  1. E value, {
  2. int compare(
    1. E a,
    2. E b
    )?,
})

Returns a position of the value in this list, if it is there.

If the list isn't sorted according to the compare function, the result is unpredictable.

If compare is omitted, this defaults to calling Comparable.compareTo on the objects. If any object is not Comparable, this throws a TypeError.

Returns -1 if value is not in the list by default.

Implementation

int binarySearch(E value, {int Function(E a, E b)? compare}) {
  return collection.binarySearch(this, value, compare: compare);
}