JsonDecode returns List<dynamic> but your another list is of type List<Map<String,String>>. So convert it to same type of list by creating to any Model and overriding == and hashcode.
and to compare two list you need ListEquality function.
example :
Function eq = const ListEquality().equals;
print(eq(list1,list2));
I tried your code and done my way, check if this okay.
Model class:
class Model {
String id;
String email;
Model({
this.id,
this.email,
});
factory Model.fromJson(Map<String, dynamic> json) => new Model(
id: json["id"],
email: json["email"],
);
Map<String, dynamic> toJson() => {
"id": id,
"email": email,
};
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Model &&
runtimeType == other.runtimeType &&
id == other.id &&
email == other.email;
@override
int get hashCode =>
id.hashCode ^
email.hashCode;
}
main.dart
import 'package:collection/collection.dart';
var body =
'{"data":{"logsread":[{"id":"9fd66092-1f7c-4e60-ab8f-5cf7e7a2dd3b","email":"email@gmail.com"}]}}';
var test1 = (jsonDecode(body)['data']['logsread'] as List)
.map((value) => Model.fromJson(value))
.toList();
var test2 = ([
{"id": "9fd66092-1f7c-4e60-ab8f-5cf7e7a2dd3b", "email": "email@gmail.com"}
]).map((value)=>Model.fromJson(value)).toList();
Function eq = const ListEquality().equals;
print(eq(test1,test2));
I hope this is what you are looking for.