I'm checking Map class. I would like to know the difference between these two below.
Are they exactly the same? What does Map.of do?
Map<int, int> m1 = Map.of({1: 1, 2: 2});
Map<int, int> m2 = <int, int>{1: 1, 2: 2};
I'm checking Map class. I would like to know the difference between these two below.
Are they exactly the same? What does Map.of do?
Map<int, int> m1 = Map.of({1: 1, 2: 2});
Map<int, int> m2 = <int, int>{1: 1, 2: 2};
Copyright © 2021 Jogjafile Inc.
check the this Dart docs
Map.of()is the same asMapinitMap.of()But my guess is that since
Mapinitialization is a variable assignment andMap.of()is a function call, the movement of the assembly is that Map assignment will be faster.