callback method

dynamic callback(
  1. Function func, [
  2. dynamic arg0,
  3. dynamic arg1,
  4. dynamic arg2,
  5. dynamic arg3,
  6. dynamic arg4,
  7. dynamic arg5,
])
inherited

Implementation

callback(Function func, [arg0, arg1, arg2, arg3, arg4, arg5]) {
  String arguments = func.runtimeType.toString().split(' => ')[0];
  if (arguments.length > 3) {
    String args = arguments.substring(1, arguments.length - 1);
    args = args.replaceAll(RegExp("<(.*)>"), "");
    int argc = args.split(', ').length;
    switch (argc) {
      case 1:
        func(arg0 ?? null);
        break;
      case 2:
        func(arg0 ?? null, arg1 ?? null);
        break;
      case 3:
        func(arg0 ?? null, arg1 ?? null, arg2 ?? null);
        break;
      case 4:
        func(arg0 ?? null, arg1 ?? null, arg2 ?? null, arg3 ?? null);
        break;
      case 5:
        func(arg0 ?? null, arg1 ?? null, arg2 ?? null, arg3 ?? null,
            arg4 ?? null);
        break;
      case 5:
        func(arg0 ?? null, arg1 ?? null, arg2 ?? null, arg3 ?? null,
            arg4 ?? null, arg5 ?? null);
        break;
    }
  } else {
    func();
  }
}