Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart optional parameter default values?

Tags:

dart

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.

like image 429
Nodeocrat Avatar asked Dec 22 '15 16:12

Nodeocrat


1 Answers

Default parameters have to be constants. You have to define your default values with the const keyword.

m([p1 = const['a', 'b']]) => null;
like image 127
Alexandre Ardhuin Avatar answered Oct 14 '22 04:10

Alexandre Ardhuin