NavigableTask.fromJson constructor

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

Implementation

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

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

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