RequestPolicy enum

Defines how data should be fetched and synchronized between local cache and remote server.

For read operations (GET):

  • cacheOnly: Only read from cache, never contact server
  • networkOnly: Only read from server, never use cache
  • cacheFirst: Return cache immediately, fetch network in background to update cache
  • networkFirst: Try network first, fallback to cache if network fails
  • cacheAndNetwork: Try network, fallback to cache on failure (legacy behavior)

For write operations (CREATE/UPDATE/DELETE):

  • cacheOnly: Write to cache only with noSync flag (never syncs to server)
  • networkOnly: Write to server only, throw error if fails
  • cacheFirst: Write to cache first, then try server in background
  • networkFirst: Write to server first, then update cache (strict, no fallback)
  • cacheAndNetwork: Try server, fallback to cache with pending sync on failure (offline-first)
Inheritance
Available extensions

Values

cacheOnly → const RequestPolicy
networkOnly → const RequestPolicy
cacheFirst → const RequestPolicy
networkFirst → const RequestPolicy
cacheAndNetwork → const RequestPolicy

Properties

hashCode → int
The hash code for this object.
no setterinherited
index → int
A numeric identifier for the enumerated value.
no setterinherited
isCache → bool

Available on RequestPolicy, provided by the RequestPolicyUtils extension

Returns true if the policy reads from or writes to cache.
no setter
isNetwork → bool

Available on RequestPolicy, provided by the RequestPolicyUtils extension

Returns true if the policy performs a synchronous network operation that blocks and returns network data immediately.
no setter
name → String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

fetch<T>({required String label, required $PocketBase client, required Future<T> remote(), required Future<T> getLocal(), required Future<void> setLocal(T)}) → Future<T>

Available on RequestPolicy, provided by the RequestPolicyUtils extension

Fetch data for read operations (GET requests).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

values → const List<RequestPolicy>
A constant List of the values in this enum, in order of their declaration.