activeFieldIndex property

int get activeFieldIndex

The index of the currently active form field.

Implementation

int get activeFieldIndex {
  final list = _fields.toList();
  if (list.isNotEmpty) {
    final idx = list.indexWhere((fs) => fs.widget.focused);
    return idx != -1 ? idx : 0;
  }
  final wIdx = widget.fields.indexWhere((f) => f.focused);
  return wIdx != -1 ? wIdx : 0;
}
set activeFieldIndex (int val)

Implementation

set activeFieldIndex(int val) {
  setState(() {
    final list = _fields.toList();
    if (list.isNotEmpty) {
      for (var i = 0; i < list.length; i++) {
        list[i].widget.focused = (i == val);
      }
      return;
    }
    if (widget.fields.isNotEmpty) {
      for (var i = 0; i < widget.fields.length; i++) {
        widget.fields[i].focused = (i == val);
      }
    }
  });
}