getSelectionParams method

Map<String, List<PickerEntity>> getSelectionParams(
  1. List<PickerEntity>? selectedResults, {
  2. bool includeUnlimitSelection = false,
})

Implementation

Map<String, List<PickerEntity>> getSelectionParams(
    List<PickerEntity>? selectedResults,
    {bool includeUnlimitSelection = false}) {
  Map<String, List<PickerEntity>> params = Map();
  if (selectedResults == null) return params;
  for (PickerEntity menuItemEntity in selectedResults) {
    int levelCount =
        MultiColumnPickerUtil.getTotalColumnCount(menuItemEntity);
    if (levelCount == 1) {
      params.addAll(getCurrentSelectionEntityParams(menuItemEntity,
          includeUnlimitSelection: includeUnlimitSelection));
    } else if (levelCount == 2) {
      params.addAll(getCurrentSelectionEntityParams(menuItemEntity,
          includeUnlimitSelection: includeUnlimitSelection));
      menuItemEntity.children.forEach((firstLevelItem) => mergeParams(
          params,
          getCurrentSelectionEntityParams(firstLevelItem,
              includeUnlimitSelection: includeUnlimitSelection)));
    } else if (levelCount == 3) {
      params.addAll(getCurrentSelectionEntityParams(menuItemEntity,
          includeUnlimitSelection: includeUnlimitSelection));
      menuItemEntity.children.forEach((firstLevelItem) {
        mergeParams(
            params,
            getCurrentSelectionEntityParams(firstLevelItem,
                includeUnlimitSelection: includeUnlimitSelection));
        firstLevelItem.children.forEach((secondLevelItem) {
          mergeParams(
              params,
              getCurrentSelectionEntityParams(secondLevelItem,
                  includeUnlimitSelection: includeUnlimitSelection));
        });
      });
    }
  }
  return params;
}