Skip to content

Commit 4ce74b3

Browse files
fix: various bugs (#762)
1 parent a76df23 commit 4ce74b3

22 files changed

+132
-77
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ unlinked_spec.ds
102102

103103
# macOS
104104
**/macos/Flutter/GeneratedPluginRegistrant.swift
105+
**/macos/flutter/ephemeral/
105106

106107
# Linux
107108
**/linux/flutter/ephemeral
@@ -120,3 +121,4 @@ app.*.symbols
120121
!**/ios/**/default.perspectivev3
121122
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
122123
!/dev/ci/**/Gemfile.lock
124+

packages/dart/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [3.1.2](https://github.com/parse-community/Parse-SDK-Flutter/compare/dart-3.1.1...dart-3.1.2) (2022-07-01)
2+
3+
### Bug Fixes
4+
5+
* unhandled exception in `ParseRelation`, type `ParseObject` is not a subtype of type ([#696](https://github.com/parse-community/Parse-SDK-Flutter/issues/696))
6+
* error in progress callback ([#679](https://github.com/parse-community/Parse-SDK-Flutter/issues/679))
7+
* incorrect return type when calling `first()` ([#661](https://github.com/parse-community/Parse-SDK-Flutter/issues/661))
8+
* error in `ParseLiveListWidget` when enabling `lazyloading` ([#653](https://github.com/parse-community/Parse-SDK-Flutter/issues/653))
9+
* unexpected null value after call `user.logout()` ([#770](https://github.com/parse-community/Parse-SDK-Flutter/issues/770))
10+
111
## [3.1.1](https://github.com/parse-community/Parse-SDK-Flutter/compare/V3.1.0...dart-3.1.1) (2022-05-30)
212

313
### Refactors

packages/dart/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ This method returns an `Future` that either resolves in an error (equivalent of
272272

273273
Choosing between `query()` and `find()` comes down to personal preference. Both methods can be used for querying a `ParseQuery`, just the output method differs.
274274

275-
Similar to `find()` the `QueryBuilder` also has a function called `Future<T>? first()`. Just like `find()` `first()` is just a convenience method that makes querying the first object satisfying the query simpler. `first()` returns an `Future`, that resoles in an error or the first object matching the query. In case no object satisfies the query, the result will be `null`.
275+
Similar to `find()` the `QueryBuilder` also has a function called `Future<T?> first()`. Just like `find()` `first()` is just a convenience method that makes querying the first object satisfying the query simpler. `first()` returns an `Future`, that resoles in an error or the first object matching the query. In case no object satisfies the query, the result will be `null`.
276276

277277
## Complex Queries
278278
You can create complex queries to really put your database to the test:
@@ -739,6 +739,13 @@ You can retrieve the ACL list of an object using:
739739
ParseACL parseACL = parseObject.getACL();
740740
```
741741

742+
To set the ACL to `ParseRole` use:
743+
744+
```dart
745+
parseACL.setReadAccess(userId: "role:ROLE_NAME", allowed: true);
746+
parseACL.setWriteAccess(userId: "role:ROLE_NAME", allowed: true);
747+
748+
```
742749
## Config
743750
The SDK supports Parse Config. A map of all configs can be grabbed from the server by calling :
744751
```dart

packages/dart/lib/src/base/parse_constants.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of flutter_parse_sdk;
22

33
// Library
4-
const String keySdkVersion = '3.1.0';
4+
const String keySdkVersion = '3.1.2';
55
const String keyLibraryName = 'Flutter Parse SDK';
66

77
// End Points

packages/dart/lib/src/network/parse_query.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ class QueryBuilder<T extends ParseObject> {
536536

537537
/// Find the first object that satisfies the query.
538538
/// Returns null, if no object is found.
539-
Future<T>? first() async {
539+
Future<T?> first() async {
540540
ParseResponse parseResponse =
541541
await (QueryBuilder.copy(this)..setLimit(1)).query();
542542
if (parseResponse.success) {

packages/dart/lib/src/objects/parse_file.dart

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class ParseFile extends ParseFileBase {
7171
final Map<String, String> headers = <String, String>{
7272
HttpHeaders.contentTypeHeader:
7373
mime(file!.path) ?? 'application/octet-stream',
74+
HttpHeaders.contentLengthHeader: '${file!.lengthSync()}',
7475
};
7576
try {
7677
final String uri = ParseCoreData().serverUrl + _path;

packages/dart/lib/src/objects/parse_relation.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ParseRelation<T extends ParseObject> {
2929
Set<T>? _knownObjects = <T>{};
3030

3131
QueryBuilder getQuery() {
32-
return QueryBuilder(ParseObject(_targetClass!))
32+
return QueryBuilder(ParseCoreData.instance.createObject(_targetClass!))
3333
..whereRelatedTo(_key, _parent!.parseClassName, _parentObjectId);
3434
}
3535

packages/dart/lib/src/objects/parse_user.dart

+10-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,16 @@ class ParseUser extends ParseObject implements ParseCloneable {
315315
/// server. Will also delete the local user data unless
316316
/// deleteLocalUserData is false.
317317
Future<ParseResponse> logout({bool deleteLocalUserData = true}) async {
318-
final String sessionId = ParseCoreData().sessionId!;
318+
final String? sessionId = ParseCoreData().sessionId;
319+
320+
if (sessionId == null) {
321+
return await _handleResponse(
322+
this,
323+
ParseNetworkResponse(data: "{}", statusCode: 200),
324+
ParseApiRQ.logout,
325+
_debug,
326+
parseClassName);
327+
}
319328

320329
forgetLocalSession();
321330

packages/dart/lib/src/utils/parse_live_list.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ class ParseLiveList<T extends ParseObject> {
144144
}),
145145
);
146146
}
147-
query.keysToReturn(keys);
147+
if (keys.isNotEmpty) {
148+
query.keysToReturn(keys);
149+
}
148150
}
149151
return await query.query<T>();
150152
}

packages/dart/pubspec.yaml

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
name: parse_server_sdk
22
description: Dart plugin for Parse Server, (https://parseplatform.org), (https://back4app.com)
3-
version: 3.1.1
4-
homepage: https://github.com/phillwiggins/flutter_parse_sdk
3+
version: 3.1.2
4+
homepage: https://github.com/parse-community/Parse-SDK-Flutter
55

66
environment:
77
sdk: ">=2.12.0 <3.0.0"
88

99
dependencies:
1010
# Networking
11-
dio: ^4.0.0
12-
http: ^0.13.3
13-
web_socket_channel: ^2.1.0
11+
dio: ^4.0.6
12+
http: ^0.13.4
13+
web_socket_channel: ^2.2.0
1414

1515
#Database
16-
sembast: ^3.1.0+2
17-
sembast_web: ^2.0.0+2
16+
sembast: ^3.2.0
17+
sembast_web: ^2.0.1+1
1818
xxtea: ^2.1.0
1919

2020
# Utils
21-
uuid: ^3.0.4
22-
meta: ^1.3.0
21+
uuid: ^3.0.6
22+
meta: ^1.7.0
2323
path: ^1.8.0
2424
mime_type: ^1.0.0
2525

26+
dependency_overrides:
27+
path: ^1.8.2 # required for transitive use only
28+
2629
dev_dependencies:
2730
lints: ^1.0.1
2831
# Testing
29-
build_runner: ^2.0.5
30-
mockito: ^5.0.10
31-
test: ^1.17.9
32+
build_runner: ^2.1.11
33+
mockito: ^5.2.0
34+
test: ^1.21.1

packages/flutter/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [3.1.3](https://github.com/parse-community/Parse-SDK-Flutter/compare/flutter-3.1.2...flutter-3.1.3) (2022-07-01)
2+
3+
### Bug Fixes
4+
5+
* old version of `connectivity_plus package` ([#717](https://github.com/parse-community/Parse-SDK-Flutter/issues/717))
6+
* dependency `package_info_plus` does not work in web ([#714](https://github.com/parse-community/Parse-SDK-Flutter/issues/714))
7+
* missing plugin exception, no implementation found for method `getAll` ([#712](https://github.com/parse-community/Parse-SDK-Flutter/issues/712))
8+
9+
110
## [3.1.2](https://github.com/parse-community/Parse-SDK-Flutter/compare/flutter-3.1.1...flutter-3.1.2) (2022-05-30)
211

312
### Refactors

packages/flutter/README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ Due to Cross-origin resource sharing (CORS) restrictions, this requires adding `
8080
When running directly via docker, set the env var `PARSE_SERVER_ALLOW_HEADERS=X-Parse-Installation-Id`.
8181
When running via express, set [ParseServerOptions](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) `allowHeaders: ['X-Parse-Installation-Id']`.
8282

83+
#### Desktop Support (macOS)
84+
The security entitlements posed by the macOS framework require that your app is granted permission to open outgoing network connections, so that the Parse Flutter SDK can communicate with Parse Server. To grant this permission, add the following lines:
85+
```
86+
<key>com.apple.security.network.client</key>
87+
<true/>
88+
```
89+
to the following files:
90+
```
91+
/macOS/Runner/Release.entitlements
92+
/macOS/Runner/DebugProfile.entitlements
93+
```
94+
to help the Parse SDK for Flutter communicate with the Web to access the server and send/retrive data.
95+
8396
#### Network client
8497
By default, this SDK uses the `ParseHTTPClient`.
8598
Another option is use `ParseDioClient`. This client supports the most features (for example a progress callback at the file upload), but a benchmark has shown, that dio is slower than http on web.
@@ -296,7 +309,7 @@ This method returns an `Future` that either resolves in an error (equivalent of
296309

297310
Choosing between `query()` and `find()` comes down to personal preference. Both methods can be used for querying a `ParseQuery`, just the output method differs.
298311

299-
Similar to `find()` the `QueryBuilder` also has a function called `Future<T>? first()`. Just like `find()` `first()` is just a convenience method that makes querying the first object satisfying the query simpler. `first()` returns an `Future`, that resoles in an error or the first object matching the query. In case no object satisfies the query, the result will be `null`.
312+
Similar to `find()` the `QueryBuilder` also has a function called `Future<T?> first()`. Just like `find()` `first()` is just a convenience method that makes querying the first object satisfying the query simpler. `first()` returns an `Future`, that resoles in an error or the first object matching the query. In case no object satisfies the query, the result will be `null`.
300313

301314
## Complex Queries
302315

@@ -844,6 +857,13 @@ You can retrieve the ACL list of an object using:
844857
ParseACL parseACL = parseObject.getACL();
845858
```
846859

860+
To set the ACL to `ParseRole` use:
861+
862+
```dart
863+
parseACL.setReadAccess(userId: "role:ROLE_NAME", allowed: true);
864+
parseACL.setWriteAccess(userId: "role:ROLE_NAME", allowed: true);
865+
```
866+
847867
## Config
848868
The SDK supports Parse Config. A map of all configs can be grabbed from the server by calling :
849869
```dart

packages/flutter/example/linux/flutter/generated_plugin_registrant.cc

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Generated file. Do not edit.
33
//
44

5+
// clang-format off
6+
57
#include "generated_plugin_registrant.h"
68

79

packages/flutter/example/linux/flutter/generated_plugin_registrant.h

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Generated file. Do not edit.
33
//
44

5+
// clang-format off
6+
57
#ifndef GENERATED_PLUGIN_REGISTRANT_
68
#define GENERATED_PLUGIN_REGISTRANT_
79

packages/flutter/example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig

-11
This file was deleted.

packages/flutter/example/macos/Flutter/ephemeral/flutter_export_environment.sh

-12
This file was deleted.

packages/flutter/lib/parse_server_sdk.dart

+5-11
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import 'package:connectivity_plus/connectivity_plus.dart';
88
import 'package:flutter/material.dart';
99
import 'package:package_info_plus/package_info_plus.dart';
1010
import 'package:parse_server_sdk/parse_server_sdk.dart' as sdk;
11+
import 'package:parse_server_sdk_flutter/src/storage/core_store_directory_io.dart'
12+
if (dart.library.html) 'package:parse_server_sdk_flutter/src/storage/core_store_directory_web.dart';
1113
import 'package:path/path.dart' as path;
12-
import 'package:path_provider/path_provider.dart';
1314
import 'package:sembast/sembast.dart';
1415
import 'package:shared_preferences/shared_preferences.dart';
1516

@@ -90,8 +91,8 @@ class Parse extends sdk.Parse
9091
parseFileConstructor: parseFileConstructor,
9192
liveListRetryIntervals: liveListRetryIntervals,
9293
connectivityProvider: connectivityProvider ?? this,
93-
fileDirectory: fileDirectory ??
94-
(!sdk.parseIsWeb ? (await getTemporaryDirectory()).path : null),
94+
fileDirectory:
95+
fileDirectory ?? (await CoreStoreDirectory().getTempDirectory()),
9596
appResumedStream: appResumedStream ?? _appResumedStreamController.stream,
9697
clientCreator: clientCreator,
9798
) as Parse;
@@ -136,14 +137,7 @@ class Parse extends sdk.Parse
136137

137138
Future<String> dbDirectory() async {
138139
String dbDirectory = '';
139-
if (!sdk.parseIsWeb &&
140-
(Platform.isIOS ||
141-
Platform.isAndroid ||
142-
Platform.isMacOS ||
143-
Platform.isLinux ||
144-
Platform.isWindows)) {
145-
dbDirectory = (await getApplicationDocumentsDirectory()).path;
146-
}
140+
dbDirectory = await CoreStoreDirectory().getDatabaseDirectory();
147141
return path.join('$dbDirectory/parse', 'parse.db');
148142
}
149143

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'package:path_provider/path_provider.dart';
2+
3+
class CoreStoreDirectory {
4+
Future<String> getDatabaseDirectory() async {
5+
return (await getApplicationDocumentsDirectory()).path;
6+
}
7+
8+
Future<String?> getTempDirectory() async {
9+
return (await getTemporaryDirectory()).path;
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CoreStoreDirectory {
2+
Future<String> getDatabaseDirectory() async {
3+
return '';
4+
}
5+
6+
Future<String?> getTempDirectory() async {
7+
return '';
8+
}
9+
}

packages/flutter/pubspec.yaml

+16-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: parse_server_sdk_flutter
22
description: Flutter plugin for Parse Server, (https://parseplatform.org), (https://back4app.com)
3-
version: 3.1.2
4-
homepage: https://github.com/phillwiggins/flutter_parse_sdk
3+
version: 3.1.3
4+
homepage: https://github.com/parse-community/Parse-SDK-Flutter
55

66
environment:
77
sdk: ">=2.12.0 <3.0.0"
@@ -10,36 +10,32 @@ dependencies:
1010
flutter:
1111
sdk: flutter
1212

13-
# Uncomment for Release version
14-
parse_server_sdk: ^3.1.1
15-
13+
parse_server_sdk: ^3.1.2
1614
# Uncomment for local testing
1715
#parse_server_sdk:
1816
# path: ../dart
1917

20-
# Uncomment for test with Github Branch
21-
#parse_server_sdk:
22-
# git:
23-
# url: https://github.com/parse-community/Parse-SDK-Flutter.git
24-
# ref: nullsafety
25-
# path: packages/dart
26-
2718
# Networking
28-
dio: ^4.0.0
29-
connectivity_plus: ^1.0.1 # only used in the flutter part
19+
dio: ^4.0.6
20+
connectivity_plus: ^2.3.2 # only used in the flutter part
3021

3122
#Database
32-
shared_preferences: ^2.0.5 # only used in the flutter part
23+
shared_preferences: ^2.0.15 # only used in the flutter part
3324

3425
# Utils
35-
path_provider: ^2.0.1 # only used in the flutter part
36-
package_info_plus: ^1.0.0 # only used in the flutter part
37-
sembast: ^3.0.0+4 # required for transitive use only
38-
path: ^1.8.0 # required for transitive use only
26+
path_provider: ^2.0.10 # only used in the flutter part
27+
package_info_plus: ^1.4.2 # only used in the flutter part
28+
sembast: ^3.2.0
29+
sembast_web: ^2.0.1+1
30+
path: ^1.8.1 # required for transitive use only
31+
32+
dependency_overrides:
33+
path: ^1.8.2 # required for transitive use only
34+
platform: ^3.1.0
3935

4036
dev_dependencies:
4137
flutter_lints: ^1.0.4
4238
# Testing
4339
flutter_test:
4440
sdk: flutter
45-
mockito: ^5.0.10
41+
mockito: ^5.2.0

tools/flutter-dependencies.bat

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
call flutter config --no-analytics
12
cd packages/dart
2-
flutter pub get
3+
call flutter pub get
34
cd ../..
45
cd packages/flutter
5-
flutter pub remove parse_server_sdk
6-
flutter pub add parse_server_sdk --path ../dart
7-
flutter pub get
6+
call flutter pub remove parse_server_sdk
7+
call flutter pub add parse_server_sdk --path ../dart
8+
call flutter pub get

tools/flutter-dependencies.sh

100755100644
File mode changed.

0 commit comments

Comments
 (0)