useContext function

BuildContext useContext()

Returns nearest BuildContext.

Implementation

BuildContext useContext() {
  var useContextHook = useHook();
  useContextHook ??= setupHook(_UseContextHook());

  if (useContextHook is! _UseContextHook) {
    throw Exception(
      'Expecting hook of type: $_UseContextHook '
      'but got: ${useContextHook.runtimeType}. '
      'Please make sure your hooks call order is not dynamic.',
    );
  }

  return useContextHook.context!;
}