getCategory function Null safety
Implementation
Future<FruitCategory?> getCategory(Iterable<Fruit> path) async {
if (path.isEmpty) {
return null;
}
FruitCategory? result = categories.value == path.first ? categories : null;
final List<Fruit> followPath = path.skip(1).toList();
while (result != null && followPath.isNotEmpty) {
result = await result.getChild(followPath.first);
followPath.removeAt(0);
}
return result;
}