1
- import 'dart:async' ;
2
-
3
1
import 'package:flutter/material.dart' ;
4
2
import 'package:flutter_plugin_example/application_constants.dart' ;
5
3
import 'package:flutter_plugin_example/diet_plan.dart' ;
6
- import 'package:parse_server_sdk/objects/parse_object.dart' ;
7
4
import 'package:parse_server_sdk/network/parse_query.dart' ;
8
- import 'package:parse_server_sdk/objects/parse_response .dart' ;
5
+ import 'package:parse_server_sdk/objects/parse_object .dart' ;
9
6
import 'package:parse_server_sdk/objects/parse_user.dart' ;
10
7
import 'package:parse_server_sdk/parse.dart' ;
11
8
@@ -17,7 +14,6 @@ class MyApp extends StatefulWidget {
17
14
}
18
15
19
16
class _MyAppState extends State <MyApp > {
20
-
21
17
@override
22
18
void initState () {
23
19
super .initState ();
@@ -35,84 +31,90 @@ class _MyAppState extends State<MyApp> {
35
31
body: new Center (
36
32
child: new Text ('Running Parse init' ),
37
33
),
38
- floatingActionButton: new FloatingActionButton (onPressed: runTestQueries),
34
+ floatingActionButton:
35
+ new FloatingActionButton (onPressed: runTestQueries),
39
36
),
40
37
);
41
38
}
42
39
43
40
initParse () async {
44
41
// Initialize parse
45
- Parse ().initialize (
46
- ApplicationConstants .PARSE_APPLICATION_ID ,
42
+ Parse ().initialize (ApplicationConstants .PARSE_APPLICATION_ID ,
47
43
ApplicationConstants .PARSE_SERVER_URL ,
48
44
masterKey: ApplicationConstants .PARSE_MASTER_KEY ,
49
45
appName: ApplicationConstants .APP_NAME ,
50
- debug: true
51
- );
46
+ debug: true );
52
47
}
53
48
54
- runTestQueries (){
55
- getAllItems ();
56
- getAllItemsByName ();
57
- getSingleItem ();
49
+ runTestQueries () {
50
+ // getAllItems();
51
+ // getAllItemsByName();
52
+ // getSingleItem();
58
53
query ();
59
- initUser ();
54
+ // initUser();
60
55
}
61
56
62
57
void getAllItemsByName () async {
63
58
var apiResponse = await ParseObject ('ParseTableName' ).getAll ();
64
59
65
- if (apiResponse.success){
60
+ if (apiResponse.success) {
66
61
for (var testObject in apiResponse.result) {
67
62
print (ApplicationConstants .APP_NAME + ": " + testObject.toString ());
68
63
}
69
64
}
70
65
}
71
66
72
67
void getAllItems () async {
73
- var dietPlans = await DietPlan ().getAll ();
74
-
75
- if (dietPlans.success) {
76
- for (var plan in dietPlans.result) {
77
- print (ApplicationConstants .APP_NAME + ": " + (plan as DietPlan ).name);
78
- }
79
- } else {
80
- print (ApplicationConstants .APP_NAME + ": " + dietPlans.exception.message);
68
+ var response = await DietPlan ().getAll ();
69
+
70
+ if (response.success) {
71
+ for (var plan in response.result) {
72
+ print (ApplicationConstants .APP_NAME + ": " + (plan as DietPlan ).name);
81
73
}
74
+ } else {
75
+ print (ApplicationConstants .APP_NAME + ": " + response.exception.message);
76
+ }
82
77
}
83
78
84
79
void getSingleItem () async {
85
- var dietPlan = await DietPlan ().get ('R5EonpUDWy' );
80
+ var response = await DietPlan ().get ('R5EonpUDWy' );
86
81
87
- if (dietPlan.success) {
88
- print (ApplicationConstants .APP_NAME + ": " + (dietPlan.result as DietPlan ).toString ());
82
+ if (response.success) {
83
+ print (ApplicationConstants .APP_NAME +
84
+ ": " +
85
+ (response.result as DietPlan ).toString ());
89
86
} else {
90
- print (ApplicationConstants .APP_NAME + ": " + dietPlan .exception.message);
87
+ print (ApplicationConstants .APP_NAME + ": " + response .exception.message);
91
88
}
92
89
}
93
90
94
- void query () {
91
+ void query () async {
95
92
// Query for an object by name
96
- QueryBuilder ()
97
- ..object = DietPlan ()
98
- ..field = DietPlan .NAME
99
- ..equals = ['Paleo' ]
100
- ..query ().then ((response) {
101
- if (response.success) {
102
- print (ApplicationConstants .APP_NAME +
103
- ": " +
104
- ((response.result as List <dynamic >).first as DietPlan )
105
- .toString ());
106
- } else {
107
- print (ApplicationConstants .APP_NAME +
108
- ": " +
109
- response.exception.message);
110
- }
111
- });
93
+ var queryBuilder = QueryBuilder <DietPlan >(DietPlan ())
94
+ ..startsWith (DietPlan .NAME , "Keto" )
95
+ ..greaterThan (DietPlan .FAT , 64 )
96
+ ..lessThan (DietPlan .FAT , 66 )
97
+ ..equals (DietPlan .CARBS , 5 );
98
+
99
+ var response = await queryBuilder.query ();
100
+
101
+ if (response.success) {
102
+ print (ApplicationConstants .APP_NAME + ": " + ((response.result as List <dynamic >).first as DietPlan ).toString ());
103
+ } else {
104
+ print (ApplicationConstants .APP_NAME + ": " + response.exception.message);
105
+ }
112
106
}
113
107
114
108
initUser () async {
115
- ParseUser ().create ("TestFlutter" , "TestPassword123" , "TestFlutterSDK@gmail.com" );
116
- ParseUser ().signUp ();
109
+ ParseUser ()
110
+ .create ("TestFlutter" , "TestPassword123" , "TestFlutterSDK@gmail.com" );
111
+ var user = await ParseUser ().signUp ();
112
+ user = await ParseUser ().login ();
113
+ user = await ParseUser ().currentUser (fromServer: true );
114
+ user = await ParseUser ().requestPasswordReset ();
115
+ user = await ParseUser ().verificationEmailRequest ();
116
+ user = await ParseUser ().all ();
117
+ user = await ParseUser ().save ();
118
+ user = await ParseUser ().destroy ();
117
119
}
118
120
}
0 commit comments