NavigableTask.fromJson constructor

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

Implementation

factory NavigableTask.fromJson(Map<String, dynamic> json) {
  final Map<StepIdentifier, NavigationRule> navigationRules = {};

  if (json['rules'] != null) {
    final rules = json['rules'] as List;
    rules.forEach((rule) {
      navigationRules.putIfAbsent(
          StepIdentifier.fromJson(rule['triggerStepIdentifier']),
          () => NavigationRule.fromJson(rule as Map<String, dynamic>));
    });
  }

  return NavigableTask(
    id: TaskIdentifier.fromJson(json),
    steps: json['steps'] != null
        ? (json['steps'] as List)
            .map((step) => Step.fromJson(step as Map<String, dynamic>))
            .toList()
        : [],
    navigationRules: navigationRules,
  );
}