focus method

  1. @override
void focus()
override

Item/component focuses itself

Implementation

@override
void focus() {
  if (_root == null) return;
  // if element does not have positive tab index attribute already specified
  // or is native element.
  // NOTE: even for elements with tab index unspecified it will return
  // tabIndex as "-1" and we have to set it to "-1"
  // to actually make it focusable.
  if (_root!.tabIndex! < 0) {
    _root!.tabIndex = -1;
  }
  _root!.focus();
}