useContext function

BuildContext useContext()

The context of the build running, in which a function that uses hooks can look up what is above it.

A hook of one's own that gives a function quitting the app:

VoidCallback useQuit() {
  final context = useContext();
  return () => AppBinding.of(context).quit();
}

Implementation

BuildContext useContext() =>
    HookElement._current ?? (throw StateError(_outside('useContext')));