بنقرة واحدة
writing-data
Writing data involves calling setItem and, optionally, setItems on a Repository.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Writing data involves calling setItem and, optionally, setItems on a Repository.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Understand how sources declare operation capabilities via supportedOperations and how SourceList respects them.
FirestoreAdminSource connects google_cloud_firestore for server-side Dart applications to a SourceList.
FirestoreSource seamlessly connects Cloud Firestore streams to a SourceList.
Perform untyped Firestore document merges using the raw method on Firestore sources.
Cached data is mapped uniquely per request hash (RequestDetails with specific filter and pagination), supporting a powerful request-based caching behavior.
The SourceList class manages the delegation of read/write attempts to various configured Sources, with a read-thru cache system prioritizing local Sources.
| name | writing-data |
| description | Writing data involves calling setItem and, optionally, setItems on a Repository. |
| metadata | {"last_modified":"Sat, 18 Apr 2026 1:52:50 GMT"} |
Writing data involves calling setItem and, optionally, setItems on a Repository.
To save a new piece of data, call setItem.
final savedItem = await myRepository.setItem(myNewObject);
If the given Repository only has local sources, this will essentially cache the given value on the user's device. If, however, the Repository has a remote source, this will attempt to save myNewObject to whatever database sits in waiting at the other end.
Filters and pagination must not be set when calling setItem or setItems, as they are read-only concepts and suggest programmer error.
By default, object Ids are expected to be set by the server when the record is saved and inserted into the database. Therefore, sources are expected to "POST" (or whatever is appropriate for your Source) new data when bindings.getId(obj) returns null and "PUT" existing data when it returns a non-null Id.
However, sometimes you may want to force a "POST" when your client has set the Id, and for this, set RequestDetails.forceInsert to true. It is then the job of your Source classes to honor this flag.
There are 4 primary types of writes one can perform, as designated by the 4 values on the RequestType enum. They are:
RequestType.local, which only calls the associated method on SourceType.local sources.RequestType.allLocal, which is invalid for writesRequestType.global, which cascades from local to remote sources, writing values everywhere.RequestType.refresh, which is invalid for writes.// Skips writing to any server and instead only caches `myObject` locally.
final items = myRepository.setItem(
myObject,
details: RequestDetails(requestType: .local),
);