Issue
List<int> l1=[1,2,3]; List<int> l2=[1,2,3]; expect (l1,l2);
This is the code I’m using in Flutter unit testing.
Eventhough both of the list has the same content I’m not able to pass the test. I’m not able to find the usecase of comparing lists using Equatable in Flutter unit testing. Can someone please help? Thanks!
Solution
You can use the method ListEquality().equals() to check if two List
are equal.
import 'package:collection/collection.dart';
List<int> l1 = [1,2,3];
List<int> l2 = [1,2,3];
final bool equal = ListEquality().equals(l1, l2):
expect(equal, true);
Answered By – quoci
Answer Checked By – Cary Denson (FlutterFixes Admin)