-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathstar_choice_answer_format.dart
More file actions
61 lines (51 loc) · 2.06 KB
/
Copy pathstar_choice_answer_format.dart
File metadata and controls
61 lines (51 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
part of '../../../model.dart';
/// Class representing an Answer Format that lets participants choose a
/// star rating
@JsonSerializable(includeIfNull: false, explicitToJson: true)
class RPStarChoiceAnswerFormat extends RPAnswerFormat {
/// A list of available [RPStarChoice] objects which represent the choices to
/// the participants.
List<RPStarChoice> choices;
/// Returns an initialized [RPStarChoiceAnswerFormat] with the given list of
/// [RPStarChoice]s.
RPStarChoiceAnswerFormat({required this.choices}) : super();
@override
RPQuestionType get questionType => RPQuestionType.ImageChoice;
@override
Function get fromJsonFunction => _$RPStarChoiceAnswerFormatFromJson;
factory RPStarChoiceAnswerFormat.fromJson(Map<String, dynamic> json) =>
FromJsonFactory().fromJson<RPStarChoiceAnswerFormat>(json);
@override
Map<String, dynamic> toJson() => _$RPStarChoiceAnswerFormatToJson(this);
}
/// The image choice object which the participants can choose from, during a
/// [RPQuestionStep] with [RPStarChoiceAnswerFormat]
@JsonSerializable(includeIfNull: false, explicitToJson: true)
class RPStarChoice extends Serializable {
/// The image portraying the choice.
String starActiveUrl;
String starNotActiveUrl;
/// The key of the image if this is to be loaded from the images
/// in the assets on the phone.
/// Specify either the [image] or the [key].
String? keyActive;
String? keyNotActive;
/// The value of the choice. Can be any type but MUST be serializable if this feature is used.
dynamic value;
/// The description fitting the image. Is displayed when selected.
String description;
RPStarChoice({
required this.starActiveUrl,
required this.starNotActiveUrl,
this.keyActive,
this.keyNotActive,
this.value,
required this.description,
}) : super();
@override
Function get fromJsonFunction => _$RPStarChoiceFromJson;
factory RPStarChoice.fromJson(Map<String, dynamic> json) =>
FromJsonFactory().fromJson<RPStarChoice>(json);
@override
Map<String, dynamic> toJson() => _$RPStarChoiceToJson(this);
}