Skip to content

Instantly share code, notes, and snippets.

@Sfshaza
Last active December 10, 2016 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sfshaza/d988cfce0a54c6853799 to your computer and use it in GitHub Desktop.
Save Sfshaza/d988cfce0a54c6853799 to your computer and use it in GitHub Desktop.
ch02
doStuff({List<int> list: const[1, 2, 3],
Map<String, String> gifts: const{'first': 'paper',
'second': 'cotton',
'third': 'leather'}}) {
print('list: $list');
print('gifts: $gifts');
}
main() {
// Use the default values for both parameters.
doStuff();
// Use the default values for the "gifts" parameter.
doStuff(list:[4,5,6]);
// Don't use the default values for either parameter.
doStuff(list: null, gifts: null);
}
@mohamedhayibor
Copy link

mohamedhayibor commented Dec 9, 2016

If you ever need to update to Optional positional parameters in response to this milestone: dart-lang/site-www#180

doStuff([List<int> list = const[1, 2, 3],
         Map<String, String> gifts = const{'first':  'paper',
                                          'second': 'cotton',
                                          'third':  'leather'}]) {
  print('list:  $list');
  print('gifts: $gifts');
}

main() {
  // Use the default values for both parameters.
  doStuff();

  // Use the default values for the "gifts" parameter.
  doStuff([4,5,6]);

  // Don't use the default values for either parameter.
  doStuff(null, null);
}

@kwalrath
Copy link

I've filed dart-lang/site-www#189 about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment