Last active
December 26, 2025 18:47
-
-
Save loic-sharma/c2f92e64dbe895aaa7a0e3e8ccd89a31 to your computer and use it in GitHub Desktop.
Dot shorthands error on map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum MyEnum { | |
| value1, | |
| value2, | |
| } | |
| void foo() { | |
| // Works as expected! | |
| final Map<MyEnum, String> myMap = <MyEnum, String>{ | |
| MyEnum.value1: 'First', | |
| .value2: 'Second', | |
| }; | |
| // Works as expected! | |
| myMap[.value2] = 'Updated First'; | |
| // Error! | |
| // The static getter 'value2' isn't defined for the context type 'Object'. | |
| // Try correcting the name to the name of an existing static getter, or defining a getter or field named 'value2'. | |
| myMap[.value2]; | |
| myMap.containsKey(.value2); | |
| myMap.remove(.value2); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment