Is it possible to check two maps are equals or not like java equals
?
void main() {
Map map1 = {'size': 38, 'color': 'red'};
Map map2 = {'size': 38, 'color': 'red'};
if(map1== map2){//both keys and values
print('yes');
}else{
print('no');
}
}
setEquals<T> function Null safety Compares two sets for element-by-element equality. Returns true if the sets are both null, or if they are both non-null, have the same length, and contain the same members. Returns false otherwise. Order is not compared.
Dart Map is an object that stores data in the form of a key-value pair. Each value is associated with its key, and it is used to access its corresponding value. Both keys and values can be any type. In Dart Map, each key must be unique, but the same value can occur multiple times.
I found mapEquals
.
import 'package:flutter/foundation.dart';
void main() {
Map map1 = {'size': 38, 'color': 'red'};
Map map2 = {'size': 38, 'color': 'red'};
if(mapEquals(map1, map2)){
print('yes');
}else{
print('no');
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With