I'm trying to compare two array values existence, but inside iterator the comparison every doesn't seem to work.
void main() {
  var array1 = [1, 2, 3, 4];
  var array2 = [2, 3, 4, 1];
  print("Arrays are equal: ${compareArrays(array1, array2)}");
}
bool compareArrays(array1, array2) {
  if (array1.length == array2.length) {
    return array1.every( (value) => array2.contains(value) );
  } else {
    return false;
  }
}
and so I'm getting below said error:
Uncaught exception: TypeError: Closure 'compareArrays_closure': type '(dynamic) => dynamic' is not a subtype of type '(int) => bool'
How could I iterate array through each values and whats wrong I'm doing above?