Skip to content

Commit 0594dd6

Browse files
committed
update to 1.0.22
2 parents 68cd891 + ba17643 commit 0594dd6

39 files changed

+555
-290
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ script:
1515

1616
cache:
1717
directories:
18-
- "$HOME/.pub-cache"
18+
- "$HOME/.pub-cache"

README.md

Lines changed: 31 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
![enter image description here](https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png)
2-
![enter image description here](https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png?fit=200%2C200&ssl=1&resize=350%2C200)
31

4-
[![Build Status](https://travis-ci.org/phillwiggins/flutter_parse_sdk.svg?branch=master)](https://travis-ci.org/phillwiggins/flutter_parse_sdk)
2+
![Parse Logo](https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png)![Flutter Logo](https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png?fit=200%2C200&ssl=1&resize=350%2C200)
53

64
## Parse For Flutter!
75
Hi, this is a Flutter plugin that allows communication with a Parse Server, (https://parseplatform.org) either hosted on your own server or another, like (http://Back4App.com).
@@ -23,30 +21,32 @@ or clone this repository and add to your project. As this is an early developmen
2321
Once you have the library added to your project, upon first call to your app (Similar to what your application class would be) add the following...
2422
2523
```dart
26-
Parse().initialize(
27-
ApplicationConstants.keyApplicationId,
28-
ApplicationConstants.keyParseServerUrl);
24+
await Parse().initialize(
25+
keyApplicationId,
26+
keyParseServerUrl);
2927
```
30-
if you want to use secure storage also that's allow using sdk on desktop application
28+
29+
If you want to use secure storage or use the Flutter web/desktop SDK, please change to the below instance of CoreStorage as it has no dependencies on Flutter.
3130
```dart
3231
33-
Parse().initialize(keyParseApplicationId, keyParseServerUrl,
34-
masterKey: keyParseMasterKey,
35-
debug: true,
36-
coreStore: CoreStoreImp.getInstance());
32+
await Parse().initialize(
33+
keyParseApplicationId,
34+
keyParseServerUrl,
35+
coreStore: await CoreStoreSembastImp.getInstance());
3736
```
38-
It's possible to add other params, such as ...
37+
It's possible to add other parameters to work with your instance of Parse Server:-
3938

4039
```dart
41-
Parse().initialize(
42-
ApplicationConstants.keyApplicationId,
43-
ApplicationConstants.keyParseServerUrl,
44-
masterKey: ApplicationConstants.keyParseMasterKey,
45-
clientKey: ApplicationConstants.keyParseClientKey,
46-
debug: true,
47-
liveQueryUrl: ApplicationConstants.keyLiveQueryUrl,
48-
autoSendSessionId: true,
49-
securityContext: securityContext);
40+
await Parse().initialize(
41+
keyApplicationId,
42+
keyParseServerUrl,
43+
masterKey: keyParseMasterKey, // Required for Back4App and others
44+
clientKey: keyParseClientKey, // Required for some setups
45+
debug: true, // When enabled, prints logs to console
46+
liveQueryUrl: keyLiveQueryUrl, // Required if using LiveQuery
47+
autoSendSessionId: true, // Some confurations require this to be true
48+
securityContext: securityContext, // Again, required for some setups
49+
coreStore: await CoreStoreSharedPrefsImp.getInstance()); // Will use SharedPreferences instead of Sembast as an internal DB
5050
```
5151

5252
## Objects
@@ -55,13 +55,13 @@ You can create custom objects by calling:
5555
var dietPlan = ParseObject('DietPlan')
5656
..set('Name', 'Ketogenic')
5757
..set('Fat', 65);
58-
await dietPlan.save()
58+
await dietPlan.save();
5959
```
6060
Verify that the object has been successfully saved using
6161
```dart
6262
var response = await dietPlan.save();
6363
if (response.success) {
64-
dietPlan = response.result;
64+
dietPlan = response.results.first;
6565
}
6666
```
6767
Types supported:
@@ -163,9 +163,9 @@ var response = await dietPlan.remove("listKeywords", ["a"]);
163163
or using with save function
164164

165165
```dart
166-
dietPlan.setAddAll('listKeywords', ['a','a','d']);
167-
dietPlan.setAddAllUnique('listKeywords', ['a','a','d']);
168-
dietPlan.setRemoveAll('listKeywords', ['a']);
166+
dietPlan.setAdd('listKeywords', ['a','a','d']);
167+
dietPlan.setAddUnique('listKeywords', ['a','a','d']);
168+
dietPlan.setRemove('listKeywords', ['a']);
169169
var response = dietPlan.save()
170170
```
171171

@@ -205,7 +205,7 @@ var queryBuilder = QueryBuilder<DietPlan>(DietPlan())
205205
var response = await queryBuilder.query();
206206
207207
if (response.success) {
208-
print(ApplicationConstants.keyAppName + ": " + ((response.result as List<dynamic>).first as DietPlan).toString());
208+
print(ApplicationConstants.keyAppName + ": " + ((response.results as List<dynamic>).first as DietPlan).toString());
209209
} else {
210210
print(ApplicationConstants.keyAppName + ": " + response.exception.message);
211211
}
@@ -295,11 +295,11 @@ The Parse Server configuration guide on the server is found here https://docs.pa
295295
Initialize the Parse Live Query by entering the parameter liveQueryUrl in Parse().initialize:
296296
```dart
297297
Parse().initialize(
298-
ApplicationConstants.keyApplicationId,
299-
ApplicationConstants.keyParseServerUrl,
300-
clientKey: ApplicationConstants.keyParseClientKey,
298+
keyApplicationId,
299+
keyParseServerUrl,
300+
clientKey: keyParseClientKey,
301301
debug: true,
302-
liveQueryUrl: ApplicationConstants.keyLiveQueryUrl,
302+
liveQueryUrl: keyLiveQueryUrl,
303303
autoSendSessionId: true);
304304
```
305305

@@ -539,21 +539,6 @@ final Map<String, String> params = <String, String>{'plan': 'paid'};
539539
function.execute(parameters: params);
540540
```
541541

542-
## Relation
543-
The SDK supports Relation.
544-
545-
To Retrive a relation instance for user, call:
546-
```dart
547-
final relation = user.getRelation('dietPlans');
548-
```
549-
550-
and then you can add a relation to the passed in object.
551-
552-
```dart
553-
relation.add(dietPlan);
554-
final result = await user.save();
555-
```
556-
557542
## Other Features of this library
558543
Main:
559544
* Installation (View the example application)
@@ -575,6 +560,3 @@ Objects:
575560

576561
## Author:-
577562
This project was authored by Phill Wiggins. You can contact me at [email protected]
578-
<!--stackedit_data:
579-
eyJoaXN0b3J5IjpbLTU4MDA4MDUwNCw3MTg2NTA0MjBdfQ==
580-
-->

example/lib/data/base/api_response.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'api_error.dart';
55
class ApiResponse {
66
ApiResponse(this.success, this.statusCode, this.results, this.error)
77
: count = results?.length ?? 0,
8-
result = results?.first;
8+
result = results?.isNotEmpty ?? false ? results.first : null;
99

1010
final bool success;
1111
final int statusCode;

example/lib/data/model/diet_plan.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ class DietPlan extends ParseObject implements ParseCloneable {
3333
set fat(num fat) => set<num>(keyFat, fat);
3434

3535
bool get status => get<bool>(keyStatus);
36+
3637
set status(bool status) => set<bool>(keyStatus, status);
3738
}

example/lib/main.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,27 @@ class _MyAppState extends State<MyApp> with AutomaticKeepAliveClientMixin {
189189
Future<void> initData() async {
190190
// Initialize repository
191191
await initRepository();
192+
final CoreStore coreStore = await initCoreStore();
192193

193194
// Initialize parse
194-
Parse().initialize(keyParseApplicationId, keyParseServerUrl,
195+
await Parse().initialize(keyParseApplicationId, keyParseServerUrl,
195196
masterKey: keyParseMasterKey,
196197
liveQueryUrl: keyParseLiveServerUrl,
197198
// clientKey: "XXXi3GejX3SIxpDgSbKHHV8uHUUP3QGiPPTlxxxx",
198199
sessionId: "1212121",
199200
autoSendSessionId: true,
200-
debug: true);
201+
debug: true,
202+
coreStore: await CoreStoreSharedPrefsImp.getInstance());
201203
// ParseHTTPClient client = ParseHTTPClient();
202204

203205
liveQuery = LiveQuery();
206+
204207
//parse serve with secure store and desktop support
205208

206209
// Parse().initialize(keyParseApplicationId, keyParseServerUrl,
207210
// masterKey: keyParseMasterKey,
208211
// debug: true,
209-
// coreStore: CoreStoreImp.getInstance());
212+
// coreStore: CoreStoreSharedPrefsImp.getInstance());
210213

211214
// Check server is healthy and live - Debug is on in this instance so check logs for result
212215
final ParseResponse response = await Parse().healthCheck();
@@ -455,7 +458,7 @@ class _MyAppState extends State<MyApp> with AutomaticKeepAliveClientMixin {
455458
if (result.success) {
456459
if (result.result is ParseObject) {
457460
final ParseObject parseObject = result.result;
458-
print(parseObject.className);
461+
print(parseObject.parseClassName);
459462
}
460463
}
461464
}
@@ -523,6 +526,14 @@ class _MyAppState extends State<MyApp> with AutomaticKeepAliveClientMixin {
523526
dietPlanRepo ??= DietPlanRepository.init(await getDB());
524527
userRepo ??= UserRepository.init(await getDB());
525528
}
529+
530+
/// Available options:
531+
/// SharedPreferences - Not secure but will work with older versions of SDK - CoreStoreSharedPrefsImpl
532+
/// Sembast - NoSQL DB - Has security - CoreStoreSembastImpl
533+
Future<CoreStore> initCoreStore() async {
534+
//return CoreStoreSembastImp.getInstance();
535+
return CoreStoreSharedPrefsImp.getInstance();
536+
}
526537
}
527538

528539
const String dietPlansToAdd =

example/lib/pages/decision_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class _DecisionPageState extends State<DecisionPage> {
6161

6262
Future<void> _initParse() async {
6363
try {
64-
Parse().initialize(keyParseApplicationId, keyParseServerUrl,
64+
await Parse().initialize(keyParseApplicationId, keyParseServerUrl,
6565
masterKey: keyParseMasterKey, debug: true);
6666
final ParseResponse response = await Parse().healthCheck();
6767
if (response.success) {

example/lib/pages/login_page.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ class _LoginPageState extends State<LoginPage> {
185185
Icons.mail,
186186
color: Colors.grey,
187187
)),
188-
validator: (String value) => value.isEmpty ? 'Email can\'t be empty' : null,
188+
validator: (String value) =>
189+
value.isEmpty ? 'Email can\'t be empty' : null,
189190
onSaved: (String value) => _email = value,
190191
),
191192
);
@@ -204,7 +205,8 @@ class _LoginPageState extends State<LoginPage> {
204205
Icons.lock,
205206
color: Colors.grey,
206207
)),
207-
validator: (String value) => value.isEmpty ? 'Password can\'t be empty' : null,
208+
validator: (String value) =>
209+
value.isEmpty ? 'Password can\'t be empty' : null,
208210
onSaved: (String value) => _password = value,
209211
),
210212
);
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
{
2-
"images" : [
2+
"images": [
33
{
4-
"idiom" : "mac",
5-
"size" : "16x16",
6-
"scale" : "1x"
4+
"idiom": "mac",
5+
"size": "16x16",
6+
"scale": "1x"
77
},
88
{
9-
"idiom" : "mac",
10-
"size" : "16x16",
11-
"scale" : "2x"
9+
"idiom": "mac",
10+
"size": "16x16",
11+
"scale": "2x"
1212
},
1313
{
14-
"idiom" : "mac",
15-
"size" : "32x32",
16-
"scale" : "1x"
14+
"idiom": "mac",
15+
"size": "32x32",
16+
"scale": "1x"
1717
},
1818
{
19-
"idiom" : "mac",
20-
"size" : "32x32",
21-
"scale" : "2x"
19+
"idiom": "mac",
20+
"size": "32x32",
21+
"scale": "2x"
2222
},
2323
{
24-
"idiom" : "mac",
25-
"size" : "128x128",
26-
"scale" : "1x"
24+
"idiom": "mac",
25+
"size": "128x128",
26+
"scale": "1x"
2727
},
2828
{
29-
"idiom" : "mac",
30-
"size" : "128x128",
31-
"scale" : "2x"
29+
"idiom": "mac",
30+
"size": "128x128",
31+
"scale": "2x"
3232
},
3333
{
34-
"idiom" : "mac",
35-
"size" : "256x256",
36-
"scale" : "1x"
34+
"idiom": "mac",
35+
"size": "256x256",
36+
"scale": "1x"
3737
},
3838
{
39-
"idiom" : "mac",
40-
"size" : "256x256",
41-
"scale" : "2x"
39+
"idiom": "mac",
40+
"size": "256x256",
41+
"scale": "2x"
4242
},
4343
{
44-
"idiom" : "mac",
45-
"size" : "512x512",
46-
"scale" : "1x"
44+
"idiom": "mac",
45+
"size": "512x512",
46+
"scale": "1x"
4747
},
4848
{
49-
"idiom" : "mac",
50-
"size" : "512x512",
51-
"scale" : "2x"
49+
"idiom": "mac",
50+
"size": "512x512",
51+
"scale": "2x"
5252
}
5353
],
54-
"info" : {
55-
"version" : 1,
56-
"author" : "xcode"
54+
"info": {
55+
"version": 1,
56+
"author": "xcode"
5757
}
5858
}

example/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dependencies:
88
# The following adds the Cupertino Icons font to your application.
99
# Use with the CupertinoIcons class for iOS style icons.
1010
cupertino_icons: ^0.1.2
11-
# flutter_stetho: ^0.2.2
1211
sembast: ^1.13.3+1
1312
shared_preferences: ^0.5.0
1413
json_table: ^0.3.0

0 commit comments

Comments
 (0)