Localizations.merge constructor Null safety

Localizations.merge(
  1. String name,
  2. List<Localizations> values
)

Implementation

factory Localizations.merge(String name, List<Localizations> values) {
  final supportedLanguageCodes = <String>[];

  Section? section;

  for (var value in values) {
    // Merging supportedLanguageCodes
    supportedLanguageCodes.addAll(
      value.supportedLanguageCodes.where(
        (x) => !supportedLanguageCodes.contains(x),
      ),
    );

    if (section == null) {
      section = value;
    } else {
      section = Section.merge(
        value,
        section,
      );
    }
  }

  return Localizations(
    name: name,
    children: section?.children ?? const <Section>[],
    labels: section?.labels ?? const <Label>[],
    supportedLanguageCodes: supportedLanguageCodes,
  );
}