@@ -88,18 +88,13 @@ class FirebaseFirestore extends FirebasePluginPlatform {
8888
8989 /// Gets a [CollectionReference] for the specified Firestore path.
9090 CollectionReference <Map <String , dynamic >> collection (String collectionPath) {
91- assert (
92- collectionPath.isNotEmpty,
93- 'a collectionPath path must be a non-empty string' ,
94- );
95- assert (
96- ! collectionPath.contains ('//' ),
97- 'a collection path must not contain "//"' ,
98- );
99- assert (
100- isValidCollectionPath (collectionPath),
101- 'a collection path must point to a valid collection.' ,
102- );
91+ if (collectionPath.isEmpty) {
92+ throw ArgumentError ('A collection path must be a non-empty string.' );
93+ } else if (collectionPath.contains ('//' )) {
94+ throw ArgumentError ('A collection path must not contain "//".' );
95+ } else if (! isValidCollectionPath (collectionPath)) {
96+ throw ArgumentError ('A collection path must point to a valid collection.' );
97+ }
10398
10499 return _JsonCollectionReference (this , _delegate.collection (collectionPath));
105100 }
@@ -214,14 +209,13 @@ class FirebaseFirestore extends FirebasePluginPlatform {
214209
215210 /// Gets a [Query] for the specified collection group.
216211 Query <Map <String , dynamic >> collectionGroup (String collectionPath) {
217- assert (
218- collectionPath.isNotEmpty,
219- 'a collection path must be a non-empty string' ,
220- );
221- assert (
222- ! collectionPath.contains ('/' ),
223- 'a collection path passed to collectionGroup() cannot contain "/"' ,
224- );
212+ if (collectionPath.isEmpty) {
213+ throw ArgumentError ('A collection path must be a non-empty string.' );
214+ }
215+ if (collectionPath.contains ('/' )) {
216+ throw ArgumentError (
217+ 'A collection path passed to collectionGroup() cannot contain "/".' );
218+ }
225219
226220 return _JsonQuery (this , _delegate.collectionGroup (collectionPath));
227221 }
@@ -237,18 +231,13 @@ class FirebaseFirestore extends FirebasePluginPlatform {
237231
238232 /// Gets a [DocumentReference] for the specified Firestore path.
239233 DocumentReference <Map <String , dynamic >> doc (String documentPath) {
240- assert (
241- documentPath.isNotEmpty,
242- 'a document path must be a non-empty string' ,
243- );
244- assert (
245- ! documentPath.contains ('//' ),
246- 'a collection path must not contain "//"' ,
247- );
248- assert (
249- isValidDocumentPath (documentPath),
250- 'a document path must point to a valid document.' ,
251- );
234+ if (documentPath.isEmpty) {
235+ throw ArgumentError ('A document path must be a non-empty string.' );
236+ } else if (documentPath.contains ('//' )) {
237+ throw ArgumentError ('A document path must not contain "//".' );
238+ } else if (! isValidDocumentPath (documentPath)) {
239+ throw ArgumentError ('A document path must point to a valid document.' );
240+ }
252241
253242 return _JsonDocumentReference (this , _delegate.doc (documentPath));
254243 }
0 commit comments