DEV Community

Discussion on: API Design: Optional Parameters

Collapse
 
vinceramces profile image
Vince Ramces Oliveros

While there's optional parameter(which might be risky if we put default values in some edge cases.). There's named parameters. which is more readable to the user. think of it as a superset of optional parameters where you don't have to initialize a value. some might think that this can be a verbose. some which might be helpful.

I didn't even know what named/optional parameters were until I used flutter.

Named parameters can be used in methods/functions, and class properties as well.

Collapse
 
samwho profile image
Sam Rose

For sure! I talk about these in the second half of the post. 😀

Collapse
 
vinceramces profile image
Vince Ramces Oliveros

From what I've understood from optional parameters is that, optional parameters have default values, while named parameters don't need. but in Dart, when declaring a named parameters/arguments, they use @required annotation that a specific argument should have a value declared when using it. Great Article by the way. Sorry if I differentiate optional and named parameters. This was something Dart clarifies me of using it when developing flutter apps.