start method Null safety

void start (
  1. String name,
  2. {Map? arguments}
)

Start a synchronous operation within this task named name. Optionally takes a Map of arguments.

Implementation

void start(String name, {Map? arguments}) {
  if (!_hasTimeline) return;
  // TODO: When NNBD is complete, delete the following line.
  ArgumentError.checkNotNull(name, 'name');
  var block = new _AsyncBlock._(name, _taskId);
  _stack.add(block);
  // TODO(39115): Spurious error about collection literal ambiguity.
  // TODO(39117): Spurious error about typing of `...?arguments`.
  // TODO(39120): Spurious error even about `...arguments`.
  // When these TODOs are done, we can use spread and if elements.
  var map = <Object?, Object?>{};
  if (arguments != null) {
    for (var key in arguments.keys) {
      map[key] = arguments[key];
    }
  }
  if (_parent != null) map['parentId'] = _parent!._taskId.toRadixString(16);
  if (_filterKey != null) map[_kFilterKey] = _filterKey;
  block._start(map);
}