equalsEach static method

bool equalsEach(
  1. List al,
  2. dynamic bl, [
  3. bool equal(
    1. dynamic a,
    2. dynamic b
    )?
])

Tests if a list equals another by comparing one-by-one *

    • equal - the closure to compare elements in the given lists.
  • If omitted, it compares each item in the list with identical().

Implementation

static bool equalsEach(List al, bl, [bool equal(a, b)?]) {
  if (identical(al, bl))
    return true;
  if (!(bl is List))
    return false;

  final bl2 = bl,
    length = al.length;
  if (length != bl2.length)
    return false;

  if (equal == null)
    equal = identical;
  for (int i = 0; i < length; i++) {
    if (!equal(al[i], bl2[i]))
      return false;
  }
  return true;
}