of static method
By passing context
, the StorageAdapter set in StorageAdapterScope can be obtained.
If the ancestor does not have StorageAdapterScope, an error will occur.
context
を渡すことによりStorageAdapterScopeで設定されたStorageAdapterを取得することができます。
祖先にStorageAdapterScopeがない場合はエラーになります。
Implementation
static StorageAdapter? of(BuildContext context) {
final scope =
context.getElementForInheritedWidgetOfExactType<_StorageAdapterScope>();
assert(
scope != null,
"StorageAdapterScope is not found. Place [StorageAdapterScope] widget closer to the root.",
);
return (scope?.widget as _StorageAdapterScope?)?.adapter;
}