fromMap static method

Solution fromMap(
  1. Map solutionData,
  2. String environment, {
  3. String language = "en",
})

Implementation

static Solution fromMap(Map solutionData, String environment,
    {String language = "en"}) {
  environmentData
      .merge(EnvironmentData.fromMap(solutionData["environmentData"]));
  setEnvironment(environment);

  stringResources
      .merge(StringResources.fromMap(solutionData["stringResources"]));
  setLanguage(language);

  final screens = (solutionData["screens"] ?? <Map>[]) as List<Map>;
  final templates = solutionData["templates"] ?? [];
  final components = solutionData["components"] ?? [];
  final actions = solutionData["actions"] ?? [];
  final requests = solutionData["types"] ?? [];
  final screenMap = <String, WidgetNodeSpec>{};
  final templateMap = <String, WidgetNodeSpec>{};
  final componentMap = <String, WidgetNodeSpec>{};
  final actionMap = <String, ActionNodeSpec>{};
  final requestMap = <String, RootNodeSpec>{};

  for (var screen in screens) {
    final node = WidgetNodeSpec.fromMap(screen);
    screenMap[node.id] = node;
    final routeName = node.props["routeName"] as String?;
    if (routeName != null && routeName.isNotEmpty) {
      screenMap[routeName] = node;
    }
  }
  for (var template in templates) {
    final node = WidgetNodeSpec.fromMap(template);
    templateMap[node.id] = node;
  }
  for (var component in components) {
    final node = WidgetNodeSpec.fromMap(component);
    componentMap[node.id] = node;
  }
  for (var action in actions) {
    final node = ActionNodeSpec.fromMap(action);
    actionMap[node.type] = node;
  }
  for (var request in requests) {
    final node = RootNodeSpec.fromMap(request);
    requestMap[node.type] = node;
  }

  return Solution._(
    solutionData["name"] ?? "",
    solutionData["type"] ?? "",
    solutionData["landingScreen"] ??
        (screens.isNotEmpty ? screens[0]["_id"] : ""),
    screenMap,
    templateMap,
    componentMap,
    actionMap,
    requestMap,
  );
}