queryAllByLabelText

List<DomNode> queryAllByLabelText(

  1. String labelText, {
  2. bool exact = true,
})

Finds all elements associated with labels containing the text.

Implementation

List<DomNode> queryAllByLabelText(String labelText, {bool exact = true}) {
  final labels = _container.querySelectorAll('label').where((label) {
    final text = label.textContent;
    return exact ? text == labelText : text.contains(labelText);
  });

final results = <DomNode>[]; for (final label in labels) { final forAttr = label.getAttribute('for'); final found = (forAttr != null) ? _container.querySelectorAll('#$forAttr') : label.querySelectorAll('input, select, textarea'); results.addAll(found); } return results; }