Reputation: 896
I know you can do this for things like Strings, ints, but I'm wondering if you can set default values for more complex data types such as Maps. I've tried with the new keyword and a few other ways, but they all throw errors.
Upvotes: 7
Views: 1982
Reputation: 657366
Default values need to be constants.
someFunc({someParam = const {'a': 'b'} }) => someParam;
Upvotes: 5
Reputation: 76213
Default parameters have to be constants. You have to define your default values with the const
keyword.
m([p1 = const['a', 'b']]) => null;
Upvotes: 7