getActiveElement function

Element? getActiveElement()

Returns the currently focused element (Document.activeElement), or null if nothing is focused (e.g. Document.activeElement is BodyElement).

Implementation

Element? getActiveElement() {
  var activeElement = document.activeElement;

  if (activeElement is! Element || activeElement == document.body) return null;

  return activeElement;
}