of static method Null safety

int of(
  1. BuildContext context
)

Returns the index of the highlighted option from the closest AutocompleteHighlightedOption ancestor.

If there is no ancestor, it returns 0.

Typical usage is as follows:

int highlightedIndex = AutocompleteHighlightedOption.of(context);

Implementation

static int of(BuildContext context) {
  return context.dependOnInheritedWidgetOfExactType<AutocompleteHighlightedOption>()?.notifier?.value ?? 0;
}