Skip to content

Instantly share code, notes, and snippets.

@micimize
Last active January 1, 2023 19:40
Show Gist options
  • Save micimize/67e428dca235e26b84c193d403a6b643 to your computer and use it in GitHub Desktop.
Save micimize/67e428dca235e26b84c193d403a6b643 to your computer and use it in GitHub Desktop.
void printKwargs({
String string = 'default',
bool boolean = false,
int integer = 1,
}) {
print([string, boolean, integer]);
}
Map<Symbol, dynamic> symbolizeKeys(Map<String, dynamic> map) =>
map.map((key, value) => MapEntry(Symbol(key), value));
void main() {
final a = {
'integer': 10,
'string': 'non-default string',
};
Function.apply(printKwargs, [], symbolizeKeys(a));
}
@hurelhuyag
Copy link

hurelhuyag commented Jan 1, 2023

Can you pass a constructor to Function.apply()?

@micimize
Copy link
Author

micimize commented Jan 1, 2023

@hurelhuyag I would guess so if tear-off constructors have been implemented in the language, but I haven't done much with dart in a while.

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