of static method

Return AppBarWithSearchSwitch in children of AppBarListener.

Note: there is a standard limitation:

  • context should be inside of AppBarListener (belong to one of it children).

Implementation

static AppBarWithSearchSwitch? of(BuildContext context) {
  final scaffold = Scaffold.maybeOf(context);
  if (scaffold != null &&
      scaffold.hasAppBar &&
      (scaffold.widget.appBar.runtimeType == AppBarWithSearchSwitch)) {
    return (scaffold.widget.appBar as AppBarWithSearchSwitch);
  }

  return null;
}