getChild method Null safety

Future<SmoothCategory<T>?> getChild(
  1. T childValue
)

Returns the child node with the value given.

Implementation

Future<SmoothCategory<T>?> getChild(T childValue) async {
  final List<SmoothCategory<T>> results = await getChildren()
      .where((SmoothCategory<T> child) => child.value == childValue)
      .toList();
  if (results.isEmpty) {
    return null;
  }
  return results.single;
}