@@ -9,24 +9,26 @@ class Query {
99 Query ._(this .method, [this .attribute = null , this .values = null ]);
1010
1111 Map <String , dynamic > toJson () {
12- final map = < String , dynamic > {'method' : method};
13-
14- if (attribute != null ) {
15- map['attribute' ] = attribute;
12+ final result = < String , dynamic > {};
13+
14+ result['method' ] = method;
15+
16+ if (attribute != null ) {
17+ result['attribute' ] = attribute;
1618 }
17-
18- if (values != null ) {
19- map ['values' ] = values is List ? values : [values];
19+
20+ if (values != null ) {
21+ result ['values' ] = values is List ? values : [values];
2022 }
2123
22- return map ;
24+ return result ;
2325 }
2426
2527 @override
2628 String toString () => jsonEncode (toJson ());
2729
2830 /// Filter resources where [attribute] is equal to [value] .
29- ///
31+ ///
3032 /// [value] can be a single value or a list. If a list is used
3133 /// the query will return resources where [attribute] is equal
3234 /// to any of the values in the list.
@@ -35,7 +37,7 @@ class Query {
3537
3638 /// Filter resources where [attribute] is not equal to [value] .
3739 static String notEqual (String attribute, dynamic value) =>
38- Query ._('notEqual' , attribute, [ value] ).toString ();
40+ Query ._('notEqual' , attribute, value).toString ();
3941
4042 /// Filter resources where [attribute] is less than [value] .
4143 static String lessThan (String attribute, dynamic value) =>
@@ -152,14 +154,14 @@ class Query {
152154 Query ._('orderDesc' , attribute).toString ();
153155
154156 /// Return results before [id] .
155- ///
157+ ///
156158 /// Refer to the [Cursor Based Pagination] (https://appwrite.io/docs/pagination#cursor-pagination)
157159 /// docs for more information.
158160 static String cursorBefore (String id) =>
159161 Query ._('cursorBefore' , null , id).toString ();
160162
161163 /// Return results after [id] .
162- ///
164+ ///
163165 /// Refer to the [Cursor Based Pagination] (https://appwrite.io/docs/pagination#cursor-pagination)
164166 /// docs for more information.
165167 static String cursorAfter (String id) =>
@@ -169,89 +171,57 @@ class Query {
169171 static String limit (int limit) => Query ._('limit' , null , limit).toString ();
170172
171173 /// Return results from [offset] .
172- ///
174+ ///
173175 /// Refer to the [Offset Pagination] (https://appwrite.io/docs/pagination#offset-pagination)
174176 /// docs for more information.
175177 static String offset (int offset) =>
176178 Query ._('offset' , null , offset).toString ();
177179
178180 /// Filter resources where [attribute] is at a specific distance from the given coordinates.
179- static String distanceEqual (
180- String attribute,
181- List <dynamic > values,
182- double distance, [
183- bool meters = true ,
184- ]) => Query ._('distanceEqual' , attribute, [
185- values,
186- distance,
187- meters,
188- ]).toString ();
181+ static String distanceEqual (String attribute, List <dynamic > values, num distance, [bool meters = true ]) =>
182+ Query ._('distanceEqual' , attribute, [[values, distance, meters]]).toString ();
189183
190184 /// Filter resources where [attribute] is not at a specific distance from the given coordinates.
191- static String distanceNotEqual (
192- String attribute,
193- List <dynamic > values,
194- double distance, [
195- bool meters = true ,
196- ]) => Query ._('distanceNotEqual' , attribute, [
197- values,
198- distance,
199- meters,
200- ]).toString ();
185+ static String distanceNotEqual (String attribute, List <dynamic > values, num distance, [bool meters = true ]) =>
186+ Query ._('distanceNotEqual' , attribute, [[values, distance, meters]]).toString ();
201187
202188 /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates.
203- static String distanceGreaterThan (
204- String attribute,
205- List <dynamic > values,
206- double distance, [
207- bool meters = true ,
208- ]) => Query ._('distanceGreaterThan' , attribute, [
209- values,
210- distance,
211- meters,
212- ]).toString ();
189+ static String distanceGreaterThan (String attribute, List <dynamic > values, num distance, [bool meters = true ]) =>
190+ Query ._('distanceGreaterThan' , attribute, [[values, distance, meters]]).toString ();
213191
214192 /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates.
215- static String distanceLessThan (
216- String attribute,
217- List <dynamic > values,
218- double distance, [
219- bool meters = true ,
220- ]) => Query ._('distanceLessThan' , attribute, [
221- values,
222- distance,
223- meters,
224- ]).toString ();
193+ static String distanceLessThan (String attribute, List <dynamic > values, num distance, [bool meters = true ]) =>
194+ Query ._('distanceLessThan' , attribute, [[values, distance, meters]]).toString ();
225195
226196 /// Filter resources where [attribute] intersects with the given geometry.
227197 static String intersects (String attribute, List <dynamic > values) =>
228- Query ._('intersects' , attribute, values).toString ();
198+ Query ._('intersects' , attribute, [ values] ).toString ();
229199
230200 /// Filter resources where [attribute] does not intersect with the given geometry.
231201 static String notIntersects (String attribute, List <dynamic > values) =>
232- Query ._('notIntersects' , attribute, values).toString ();
202+ Query ._('notIntersects' , attribute, [ values] ).toString ();
233203
234204 /// Filter resources where [attribute] crosses the given geometry.
235205 static String crosses (String attribute, List <dynamic > values) =>
236- Query ._('crosses' , attribute, values).toString ();
206+ Query ._('crosses' , attribute, [ values] ).toString ();
237207
238208 /// Filter resources where [attribute] does not cross the given geometry.
239209 static String notCrosses (String attribute, List <dynamic > values) =>
240- Query ._('notCrosses' , attribute, values).toString ();
210+ Query ._('notCrosses' , attribute, [ values] ).toString ();
241211
242212 /// Filter resources where [attribute] overlaps with the given geometry.
243213 static String overlaps (String attribute, List <dynamic > values) =>
244- Query ._('overlaps' , attribute, values).toString ();
214+ Query ._('overlaps' , attribute, [ values] ).toString ();
245215
246216 /// Filter resources where [attribute] does not overlap with the given geometry.
247217 static String notOverlaps (String attribute, List <dynamic > values) =>
248- Query ._('notOverlaps' , attribute, values).toString ();
218+ Query ._('notOverlaps' , attribute, [ values] ).toString ();
249219
250220 /// Filter resources where [attribute] touches the given geometry.
251221 static String touches (String attribute, List <dynamic > values) =>
252- Query ._('touches' , attribute, values).toString ();
222+ Query ._('touches' , attribute, [ values] ).toString ();
253223
254224 /// Filter resources where [attribute] does not touch the given geometry.
255225 static String notTouches (String attribute, List <dynamic > values) =>
256- Query ._('notTouches' , attribute, values).toString ();
257- }
226+ Query ._('notTouches' , attribute, [ values] ).toString ();
227+ }
0 commit comments