loadSolutionsFromMaps static method

void loadSolutionsFromMaps(
  1. List<Map> solutions,
  2. String environment, {
  3. String language = "en",
})

Implementation

static void loadSolutionsFromMaps(List<Map> solutions, String environment,
    {String language = "en"}) {
  if (solutions.isEmpty) {
    return;
  }

  var name = "";
  var landingScreen = "";
  final createdSolutions = <Solution>[];

  for (var solution in solutions) {
    if (solution["landingScreen"] != null &&
        solution["landingScreen"].isNotEmpty) {
      landingScreen = solution["landingScreen"];
    }
    var newSolution =
        Solution.fromMap(solution, environment, language: language);
    createdSolutions.add(newSolution);
    if (newSolution.name.isNotEmpty) {
      name = newSolution.name;
    }
  }

  if (landingScreen.isEmpty && createdSolutions.isNotEmpty) {
    landingScreen = createdSolutions.last.landingScreen;
  }

  final solution = Solution.empty(name, environment,
      language: language, landingScreen: landingScreen);
  for (var createdSolution in createdSolutions) {
    solution.merge(createdSolution);
  }
  _solution = solution;
}