2.0 Migration Problem.. #6043
-
I am working on a 2.0 migration.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
When writing code snippets, make sure they're legible for others to better help you. Please use highlighting and proper formatting. Darts language code is As for a way you can create a stream of product docs (if this is what you want) you can creating a stream of the snapshots and then consume that stream in another provider that exposes just the docs (This helps you separate concerns, the mapping of docs from the source stream). final serviceProductSnapshotsProvider =
StreamProvider.autoDispose<QuerySnapshot<ServiceProduct>>(
(ref) => serviceProductCollectionRef.snapshots(),
);
final serviceProductDocsProvider =
Provider.autoDispose<AsyncValue<List<DocumentSnapshot<ServiceProduct>>>>(
(ref) {
return ref.watch(serviceProductSnapshotsProvider).whenData((snapshot) {
return snapshot.docs;
});
},
); Or, if you prefer to just get the docs, you can do final serviceProductDocsProvider =
StreamProvider.autoDispose<List<QueryDocumentSnapshot<ServiceProduct>>>(
(ref) => serviceProductCollectionRef.snapshots().map((snapshot) => snapshot.docs),
); |
Beta Was this translation helpful? Give feedback.
When writing code snippets, make sure they're legible for others to better help you.
Please use highlighting and proper formatting. Darts language code is
dart
.As for a way you can create a stream of product docs (if this is what you want) you can creating a stream of the snapshots and then consume that stream in another provider that exposes just the docs (This helps you separate concerns, the mapping of docs from the source stream).