2
list1=["hello World","hello India"]

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

how could I check equality of this two list

Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40
  • 3
    Does this answer your question? [How can I compare Lists for equality in Dart?](https://stackoverflow.com/questions/10404516/how-can-i-compare-lists-for-equality-in-dart) – Thiago Fontes Sep 13 '22 at 11:18

2 Answers2

2

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()));
}
Ivo
  • 18,659
  • 2
  • 23
  • 35
-1

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

Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40