findControlInCollection method

AbstractControl? findControlInCollection(
  1. List<String> path
)

Walks the path to find the matching control.

Returns null if no match is found.

Implementation

AbstractControl<dynamic>? findControlInCollection(List<String> path) {
  if (path.isEmpty) {
    return null;
  }

  final result = path.fold<AbstractControl<dynamic>?>(this, (control, name) {
    if (control != null && control is FormControlCollection<dynamic>) {
      return control.contains(name) ? control.control(name) : null;
    } else {
      return null;
    }
  });

  return result;
}