Skip to content

RPStepResult

The result from a RPStep.

Inheritance
Annotations

Constructors

RPStepResult.fromJson

RPStepResult.fromJson(
  1. Map<String, dynamic> json
)

RPStepResult

RPStepResult({
  1. required String identifier,
  2. required String questionTitle,
  3. required RPAnswerFormat answerFormat,
})

Create a RPStepResult with a given identifier and an empty map of results.

It sets startDate to the DateTime.now(). Since these objects are instantiated together with the Step it belongs to so it can be used for measuring how much time the participant spent the given Step.

Constants

DEFAULT_KEY

  1. @JsonKey(includeFromJson: false, includeToJson: false)
String const DEFAULT_KEY

The default key for the results map. It's used when there's only one answer result. In that case the result value is saved under this key in the map.

Properties

answerFormat

RPAnswerFormat answerFormat
getter/setter pair

The Answer Format (RPAnswerFormat) which generated this result.

It stores the details about the question (e.g. the available choices) therefore it's necessary for understanding the value of the result which usually doesn't tell a lot in itself.

fromJsonFunction

Function get fromJsonFunction
override

The function which can convert a JSON string to an object of this type.

questionTitle

String questionTitle
getter/setter pair

The title of the question.

It is set by the RPStep and RPUIFormStep so it's easier to trace back this answer result from the step that initiated it.

results

Map<String, dynamic> results
getter/setter pair

The map of results with a string as identifier and generic type as value.

Methods

getResultForIdentifier

dynamic getResultForIdentifier(
  1. String identifier
)

Returns result value for the given identifier from the results map

setResult

void setResult(
  1. dynamic result
)

Creates an entry for the results map with the default key.

Usually it's used when there's only one result produced by the Question Body

setResultForIdentifier

void setResultForIdentifier(
  1. String identifier,
  2. dynamic result
)

Adds a result to the result map with the given identifier.

Used when the result is not a traditional answer result (e.g. signature result). Also used at Form Steps where there are multiple questions asked during a single step.

toJson

Map<String, dynamic> toJson()
override

Return a JSON encoding of this object.