Skip to content

[cloud_firestore] DocumentSnapshot promotion or null safe data #6060

Discussion options

You must be logged in to vote

You should be able to implement that with an extension:

extension<T> on DocumentSnapshot<T> {
  T get requiredData {
     final value = data();
     if (!value.exists) throw Error('not found');
     return value as T;
  }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stargazing-dino
Comment options

Answer selected by stargazing-dino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants