check equality of two list how to check the elements of both them are equal not in index wise

Viewed 31
list1=["hello World","hello India"]

list2=["hello India","hello world"]

how could I check equality of this two list

2 Answers

You can try compare sorted copies of the lists, like

import 'package:collection/collection.dart';

void main() {
  var list1 = ["hello world","hello India"];
  var list2 = ["hello India", "hello world"];

  print(ListEquality().equals(list1.toList()..sort(), list2.toList()..sort()));
}

Try below code refer collection

import 'package:collection/collection.dart';

void main() {
  List list1 = ["hello World", "hello India"]; 
  List list2 = ["hello India", "hello world"];

  print(ListEquality().equals(list1, list2));
}

Result - false

Related