Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Firestore: Allow null document snapshot data when document does not exist #406

Merged

Conversation

pulyaevskiy
Copy link
Contributor

Fixes following exception when getting document snapshot when the document does not exist yet:

NoSuchMethodError: The method 'forEach' was called on null.
  Receiver: null
  Tried calling: forEach(Closure: (dynamic, dynamic) => dynamic)
  dart:collection                                            new LinkedHashMap.from
  package:cloud_firestore/src/document_snapshot.dart 36:16   _asStringKeyedMap
  package:cloud_firestore/src/document_reference.dart 58:7   DocumentReference.get

I also added DocumentSnapshot.exists to match implementations in other languages (Java/Node.js/ObjC).

@kroikie kroikie self-assigned this Mar 5, 2018
@kroikie
Copy link
Contributor

kroikie commented Mar 5, 2018

@pulyaevskiy thanks for the PR. Looks good to me.

@collinjackson
Copy link
Contributor

lgtm

@kroikie kroikie merged commit 0f4622a into flutter:master Mar 5, 2018
jonasbark pushed a commit to jonasbark/plugins that referenced this pull request Mar 20, 2018
* commit 'a404fbfd4842b51b57bc0c6298604cf5674e2c02': (40 commits)
  Update README.md (flutter#430)
  Updated to 0.5.0 (flutter#428)
  AdSizes for AdMob banner ads (flutter#402)
  bump minor version and add changelog entry (flutter#427)
  add fetchProvidersForEmail wrapper (flutter#410)
  Incremental Build Script (flutter#422)
  add runtime permission requests for external storage and camera (flutter#424)
  Fix Dart 2 type error and deprecation (flutter#425)
  Fix a Dart 2 runtime cast failure in firebase_database test (flutter#419)
  Fixed deprecation warnings (flutter#420)
  Fix Dart 2 runtime error in the camera plugin (flutter#417)
  Always use the latest Flutter available (flutter#415)
  Spelling (flutter#411)
  Configure Flutter CI (flutter#383)
  Set SDK constraints to match Flutter beta (flutter#412)
  Remove Gradle artifacts from repo (flutter#414)
  Google maps plugin stub (flutter#405)
  Allow null document snapshot data when document does not exist (flutter#406)
  Fix new formatting errors (flutter#408)
  Fix url_launcher for iOS <10 (flutter#407)
  ...
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants