W3cubDocs

/Dart 2

apply method

dynamic apply (Function function, List positionalArguments, [ Map<Symbol, dynamic> namedArguments ])

Dynamically call function with the specified arguments.

Acts the same as calling function with positional arguments corresponding to the elements of positionalArguments and named arguments corresponding to the elements of namedArguments.

This includes giving the same errors if function isn't callable or if it expects different parameters.

Example:

Function.apply(foo, [1,2,3], {#f: 4, #g: 5});

gives exactly the same result as

foo(1, 2, 3, f: 4, g: 5).

If positionalArguments is null, it's considered an empty list. If namedArguments is omitted or null, it is considered an empty map.

Implementation

external static apply(Function function, List positionalArguments,
    [Map<Symbol, dynamic> namedArguments]);

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-core/Function/apply.html