findControlInCollection method
Walks the path
to find the matching control.
Returns null if no match is found.
Implementation
AbstractControl<Object>? findControlInCollection(List<String> path) {
if (path.isEmpty) {
return null;
}
final result = path.fold(this as AbstractControl<Object>, (control, name) {
if (control is FormControlCollection<dynamic>) {
final collection = control;
return collection.contains(name) ? collection.control(name) : null;
} else {
return null;
}
});
return result != null ? result as AbstractControl<Object> : null;
}