end method

dynamic end([
  1. dynamic log,
  2. LogType? type
])

结束当前Flow

Implementation

end([dynamic log, LogType? type]) {
  if (log != null) {
    if (type == LogType.error) {
      _hasError = true;
    }
    this.logs!.add(Log(log, type ?? LogType.log));
  }

  timer?.cancel();
  timer = null;
  _endAt = DateTime.now();
  final newLog = FlowLog._(
    name: name,
    logs: List.from(logs!),
    timeout: timeout,
    createdAt: createdAt,
    end: endAt,
    id: id,
    hasError: _hasError,
  );
  // 拷贝一份去
  FlowCenter.instance.flowList.add(newLog);
  _emit(FlowLogEvent.end, newLog);
  this.createdAt = DateTime.now();
  this._endAt = null;
  FlowCenter.instance.workingFlow.remove(name + id);
  this.logs!.clear();
  FlowCenter.instance._notify();
}