categories property Null safety

List<Category> categories

All categories declared in all label cases conditions.

Implementation

List<Category> get categories {
  final categories = <String, Set<String>>{};

  final allConditions =
      allLabels.expand((x) => x.categoryConditions).toList();

  for (var condition in allConditions) {
    final category = categories.putIfAbsent(
      condition.name,
      () => <String>{},
    );
    category.add(condition.value);
  }

  return categories.entries
      .map(
        (x) => Category(
          name: x.key,
          values: x.value,
        ),
      )
      .toList();
}