MBViewTrigger.fromDictionary constructor
Initializes a view trigger with the data of the dictionary returned by the APIs.
Implementation
factory MBViewTrigger.fromDictionary(Map<String, dynamic> dictionary) {
String id = dictionary['id'] ?? '';
String view = dictionary['view'] ?? '';
int times = 0;
if (dictionary['times'] is int) {
times = dictionary['times'];
} else if (dictionary['times'] is String) {
times = int.tryParse(dictionary['times']) ?? 0;
}
int secondsOnView = 0;
if (dictionary['seconds_on_view'] is int) {
secondsOnView = dictionary['seconds_on_view'];
} else if (dictionary['seconds_on_view'] is String) {
secondsOnView = int.tryParse(dictionary['seconds_on_view']) ?? 0;
}
return MBViewTrigger(
id: id,
view: view,
times: times,
secondsOnView: secondsOnView,
);
}