of static method

int of(
  1. BuildContext context
)

Returns the index of the highlighted option from the closest PerfectAutocompleteHighlightedOption 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<
              PerfectAutocompleteHighlightedOption>()
          ?.notifier
          ?.value ??
      0;
}