buildArgs method

  1. @mustCallSuper
Args buildArgs()

Builds the arguments using either the set args or the args factory.

This method must be called before accessing args. Throws a StateError if neither setArgs nor setArgsFactory has been called, unless Args is void.

@return The built arguments.

Implementation

@mustCallSuper
Args buildArgs() {
  Type getType<T>() => T;
  final voidType = getType<void>();

  final requiredArgs = _args ?? _argsFactory?.call();
  if (requiredArgs == null && Args != voidType) {
    throw StateError('args is required');
  }
  this.args = requiredArgs as Args;

  return args;
}