maybeOf static method

TreeViewController? maybeOf(
  1. BuildContext context
)

Finds the TreeView from the closest instance of this class that encloses the given context and returns its TreeViewController.

If no TreeView encloses the given context then return null. To throw an exception instead, use of instead of this function.

See also:

  • of, a similar function to this one that throws if no TreeView encloses the given context. Also includes some sample code in its documentation.

Implementation

static TreeViewController? maybeOf(BuildContext context) {
  return context
      .findAncestorStateOfType<_TreeViewState<Object?>>()
      ?.controller;
}