ChoosePathString method

  1. @override
void ChoosePathString(
  1. String path, {
  2. bool resetCallstack = true,
  3. List<Object> arguments = const [],
})

Implementation

@override
void ChoosePathString(String path,
    {bool resetCallstack = true, List<Object> arguments = const []}) {
  onChoosePathString?.call(path, arguments);

  if (resetCallstack) {
    ResetCallstack();
  } else {
    // ChoosePathString is potentially dangerous since you can call it when the stack is
    // pretty much in any state. Let's catch one of the worst offenders.
    if (state.callStack.currentElement.type == PushPopType.Function) {
      String funcDetail = "";
      var container = state.callStack.currentElement.currentPointer.container;
      if (container != null) {
        funcDetail = "(" + container.path.toString() + ") ";
      }
      throw Exception("Story was running a function " +
          funcDetail +
          "when you called ChoosePathString(" +
          path +
          ") - this is almost certainly not not what you want! Full stack trace: \n" +
          state.callStack.callStackTrace);
    }
  }
  state.PassArgumentsToEvaluationStack(arguments);

  choosePath(Path(path));
}