getCategorySiblingsAndFather method Null safety

Future<Map<String, dynamic>?> getCategorySiblingsAndFather(
  1. {required String fatherTag}
)

Returns the siblings AND the father (for tree climbing reasons).

Implementation

Future<Map<String, TaxonomyCategory>?> getCategorySiblingsAndFather({
  required final String fatherTag,
}) async {
  final Map<String, TaxonomyCategory> fatherData =
      await _getCategories(<String>[fatherTag]);
  if (fatherData.isEmpty) {
    return null;
  }
  final List<String>? siblingTags = fatherData[fatherTag]?.children;
  if (siblingTags == null || siblingTags.isEmpty) {
    return fatherData;
  }
  final Map<String, TaxonomyCategory> result =
      await _getCategories(siblingTags);
  if (result.isNotEmpty) {
    result[fatherTag] = fatherData[fatherTag]!;
  }
  return result;
}