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 asMap
initMap.of()
But my guess is that since
Map
initialization is a variable assignment andMap.of()
is a function call, the movement of the assembly is that Map assignment will be faster.