I'm trying to call a function in dart with a set of parameters that is provided in an array. I want to be able to pass the parameters to the function without knowing how many parameters there will be.
Ex:
someFunc(var a, var b, var c) {...}
paramArray = [1,2,3];
callFunction(var func, var params) {
//Here is a sloppy workaround to what I want the functionality to be
switch(params.length) {
case 0:
func()
break;
case 1:
func(params[0])
break;
case 2:
func(params[0], params[1])
break;
...
}
}
callFunction(someFunc, paramArray);
Does there exist a cleaner way to do this in dart without changing the signature of someFunc?