run method

Future<String> run(
  1. dynamic input
)

Convenience method for executing chain when there's a single string output.

The main difference between this method and call is that this method can only be used for chains that return a single string output. If a Chain has more outputs, the output is not a string, or you want to return the inputs/run info along with the outputs, use call.

If run is called on a chain that does not return a string, Object.toString will be called on the output.

The input can be:

  • A single value, if the chain has a single input key. Eg: chain.run('Hello world!')
  • A map of key->values, if the chain has multiple input keys. Eg: chain.run({'foo': 'Hello', 'bar': 'world!'})

Implementation

Future<String> run(final dynamic input) async {
  final outputKey = runOutputKey;
  final returnValues = await call(input, returnOnlyOutputs: true);
  return returnValues[outputKey].toString();
}