start 方法

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

在本任务中启动名为 name 的同步操作。可选地接受一个 Maparguments

实现

void start(String name, {Map? arguments}) {
  if (!_hasTimeline) return;
  // TODO: When NNBD is complete, delete the following line.
  ArgumentError.checkNotNull(name, 'name');
  if (!_isDartStreamEnabled()) {
    // Push a null onto the stack and return.
    _stack.add(null);
    return;
  }
  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);
}