of static method

AuthAdapter? of(
  1. BuildContext context
)

By passing context, the AuthAdapter set in AuthAdapterScope can be obtained.

If the ancestor does not have AuthAdapterScope, an error will occur.

contextを渡すことによりAuthAdapterScopeで設定されたAuthAdapterを取得することができます。

祖先にAuthAdapterScopeがない場合はエラーになります。

Implementation

static AuthAdapter? of(BuildContext context) {
  final scope =
      context.getElementForInheritedWidgetOfExactType<_AuthAdapterScope>();
  assert(
    scope != null,
    "AuthAdapterScope is not found. Place [AuthAdapterScope] widget closer to the root.",
  );
  return (scope?.widget as _AuthAdapterScope?)?.adapter;
}